Skip to content

Commit

Permalink
Pass name into offsets
Browse files Browse the repository at this point in the history
  • Loading branch information
yamiteru committed Apr 2, 2023
1 parent c43e65a commit 55460a5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
5 changes: 3 additions & 2 deletions src/offset/getOffset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ import {
OFFSET_KEYS,
OFFSET_MAX,
} from "../constants";
import { Name } from "../events";
import { stats } from "../stats";
import { TypeMode } from "../types";

export async function getOffset({ type, mode }: TypeMode) {
export async function getOffset(name: Name, { type, mode }: TypeMode) {
const fn = type === "async" ? FN_ASYNC : FN_SYNC;
const result = { ...OFFSET };

while (true as any) {
const offset = await stats(fn, mode, OFFSETS);
const offset = await stats(name, fn, mode, OFFSETS);

let counter = 0;

Expand Down
11 changes: 6 additions & 5 deletions src/offset/getOffsets.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { getOffset } from "./getOffset";
import { Offsets } from "../types";
import { Name } from "../events";

export async function getOffsets(): Promise<Offsets> {
export async function getOffsets(name: Name): Promise<Offsets> {
return {
async: {
cpu: await getOffset({ type: "async", mode: "cpu" }),
ram: await getOffset({ type: "async", mode: "ram" }),
cpu: await getOffset(name, { type: "async", mode: "cpu" }),
ram: await getOffset(name, { type: "async", mode: "ram" }),
},
sync: {
cpu: await getOffset({ type: "sync", mode: "cpu" }),
ram: await getOffset({ type: "sync", mode: "ram" }),
cpu: await getOffset(name, { type: "sync", mode: "cpu" }),
ram: await getOffset(name, { type: "sync", mode: "ram" }),
},
};
}
2 changes: 1 addition & 1 deletion src/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function preset(partialOptions?: DeepPartial<Options>) {
GLOBAL.stores = stores;
GLOBAL.options = options;

const offsets = await getOffsets();
const offsets = await getOffsets(suite);

await pub($suiteOffsets, { suite, offsets });

Expand Down

0 comments on commit 55460a5

Please sign in to comment.