generated from yamiteru/ts-package
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
19 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,34 @@ | ||
import { createPreset } from "../src"; | ||
import { useTerminal } from "../src/modes"; | ||
import { useTerminal } from "../src"; | ||
import { suite } from "../src"; | ||
|
||
const LENGTH = 1_000; | ||
const DATA = [...new Array(LENGTH)].map(() => Math.random() * 10); | ||
const RESULT = { _: 0 }; | ||
|
||
const defaultSuite = createPreset(); | ||
const emptyFunctions = defaultSuite("Array loops", { | ||
for: () => { | ||
const emptyFunctions = suite("Array loops") | ||
.add("for", () => { | ||
for (let i = 0; i < LENGTH; ++i) { | ||
RESULT._ = DATA[i]; | ||
} | ||
}, | ||
while: () => { | ||
}) | ||
.add("while", () => { | ||
let i = -1; | ||
|
||
while (++i < LENGTH) { | ||
RESULT._ = DATA[i]; | ||
} | ||
}, | ||
forOf: () => { | ||
}) | ||
.add("forOf", () => { | ||
for (const v of DATA) { | ||
RESULT._ = v; | ||
} | ||
}, | ||
forEach: () => { | ||
}) | ||
.add("forEach", () => { | ||
DATA.forEach((v) => (RESULT._ = v)); | ||
}, | ||
}); | ||
}); | ||
|
||
(async () => { | ||
useTerminal(); | ||
|
||
await emptyFunctions(); | ||
await emptyFunctions.run(); | ||
})(); |
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,18 +1,16 @@ | ||
import { createPreset } from "../src"; | ||
import { suite } from "../src"; | ||
import { useTerminal } from "../src/modes"; | ||
|
||
const defaultSuite = createPreset(); | ||
const emptyFunctions = defaultSuite("Empty functions", { | ||
emptyAsync: async () => { | ||
const emptyFunctions = suite("Empty functions") | ||
.add("empty async", async () => { | ||
/* */ | ||
}, | ||
emptySync: () => { | ||
}) | ||
.add("empty sync", () => { | ||
/* */ | ||
}, | ||
}); | ||
}); | ||
|
||
(async () => { | ||
useTerminal(); | ||
|
||
await emptyFunctions(); | ||
await emptyFunctions.run(); | ||
})(); |