Skip to content

Commit

Permalink
Update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
yamiteru committed Apr 4, 2023
1 parent 8e238b7 commit fa19e06
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 23 deletions.
26 changes: 12 additions & 14 deletions examples/arrayLoops.ts
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();
})();
16 changes: 7 additions & 9 deletions examples/emptyFunctions.ts
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();
})();

0 comments on commit fa19e06

Please sign in to comment.