-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: Simple profiler for
BuiltinLogger
(#1945)
Maybe not so simple
- Loading branch information
Showing
12 changed files
with
175 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,12 @@ | ||
import { bench, describe } from "vitest"; | ||
import { formatDuration } from "../../src/logger-helpers"; | ||
|
||
describe.skip("Experiment", () => { | ||
const originalFn = () => {}; | ||
describe.each([0.555, 555, 55555555])("Experiment", (ms) => { | ||
bench("original", () => { | ||
formatDuration(ms); | ||
}); | ||
|
||
bench( | ||
"original", | ||
() => { | ||
originalFn(); | ||
}, | ||
{ time: 5000 }, | ||
); | ||
|
||
bench("featured", () => {}, { time: 5000 }); | ||
bench("featured", () => { | ||
formatDuration(ms); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`Logger helpers > formatDuration() > 0 should format 1e-9 ms 1`] = `"1 picosecond"`; | ||
|
||
exports[`Logger helpers > formatDuration() > 1 should format 1e-8 ms 1`] = `"10 picoseconds"`; | ||
|
||
exports[`Logger helpers > formatDuration() > 2 should format 1e-7 ms 1`] = `"100 picoseconds"`; | ||
|
||
exports[`Logger helpers > formatDuration() > 3 should format 0.000001 ms 1`] = `"1 nanosecond"`; | ||
|
||
exports[`Logger helpers > formatDuration() > 4 should format 0.00001 ms 1`] = `"10 nanoseconds"`; | ||
|
||
exports[`Logger helpers > formatDuration() > 5 should format 0.0001 ms 1`] = `"100 nanoseconds"`; | ||
|
||
exports[`Logger helpers > formatDuration() > 6 should format 0.001 ms 1`] = `"1 microsecond"`; | ||
|
||
exports[`Logger helpers > formatDuration() > 7 should format 0.01 ms 1`] = `"10 microseconds"`; | ||
|
||
exports[`Logger helpers > formatDuration() > 8 should format 0.1 ms 1`] = `"100 microseconds"`; | ||
|
||
exports[`Logger helpers > formatDuration() > 9 should format 1 ms 1`] = `"1 millisecond"`; | ||
|
||
exports[`Logger helpers > formatDuration() > 10 should format 10 ms 1`] = `"10 milliseconds"`; | ||
|
||
exports[`Logger helpers > formatDuration() > 11 should format 100 ms 1`] = `"100 milliseconds"`; | ||
|
||
exports[`Logger helpers > formatDuration() > 12 should format 1000 ms 1`] = `"1 second"`; | ||
|
||
exports[`Logger helpers > formatDuration() > 13 should format 1500 ms 1`] = `"1.5 seconds"`; | ||
|
||
exports[`Logger helpers > formatDuration() > 14 should format 10000 ms 1`] = `"10 seconds"`; | ||
|
||
exports[`Logger helpers > formatDuration() > 15 should format 100000 ms 1`] = `"1.67 minutes"`; | ||
|
||
exports[`Logger helpers > formatDuration() > 16 should format 1000000 ms 1`] = `"16.67 minutes"`; | ||
|
||
exports[`Logger helpers > formatDuration() > 17 should format 10000000 ms 1`] = `"166.67 minutes"`; | ||
|
||
exports[`Logger helpers > formatDuration() > 18 should format 100000000 ms 1`] = `"1666.67 minutes"`; | ||
|
||
exports[`Logger helpers > formatDuration() > 19 should format 1000000000 ms 1`] = `"16666.67 minutes"`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters