mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-09 19:51:41 +00:00
add performance measures
This commit is contained in:
parent
c68561d87d
commit
6c0519bd36
@ -67,17 +67,3 @@ export class GildedRose {
|
|||||||
return this.items;
|
return this.items;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const startTime = performance.now();
|
|
||||||
|
|
||||||
// Call the function
|
|
||||||
const gildedRose = new GildedRose([]);
|
|
||||||
gildedRose.updateQuality();
|
|
||||||
|
|
||||||
// Record end time
|
|
||||||
const endTime = performance.now();
|
|
||||||
|
|
||||||
// Calculate the time difference
|
|
||||||
const timeTaken = endTime - startTime;
|
|
||||||
|
|
||||||
console.log(`myFunction took ${timeTaken.toFixed(2)} ms to execute.`);
|
|
||||||
|
|||||||
@ -3,7 +3,11 @@ import { Item, GildedRose } from '@/gilded-rose';
|
|||||||
describe('Gilded Rose', () => {
|
describe('Gilded Rose', () => {
|
||||||
it('should foo', () => {
|
it('should foo', () => {
|
||||||
const gildedRose = new GildedRose([new Item('foo', 0, 0)]);
|
const gildedRose = new GildedRose([new Item('foo', 0, 0)]);
|
||||||
|
const startTime = performance.now();
|
||||||
const items = gildedRose.updateQuality();
|
const items = gildedRose.updateQuality();
|
||||||
expect(items[0].name).toBe('fixme');
|
const endTime = performance.now();
|
||||||
|
|
||||||
|
console.log('Execution time: ' + (endTime - startTime) + 'ms');
|
||||||
|
expect(items[0].name).toBe('foo');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user