-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(xsnap): performance monitoring / metering #3023
- Loading branch information
Showing
8 changed files
with
129 additions
and
28 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,3 +1,3 @@ | ||
[submodule "packages/xsnap/moddable"] | ||
path = packages/xsnap/moddable | ||
url = https://github.com/Moddable-OpenSource/moddable.git | ||
url = https://github.com/agoric-labs/moddable.git |
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
import test from 'ava'; | ||
import { xsnap } from '../src/xsnap'; | ||
import { options } from './test-xsnap'; | ||
|
||
test('meter details', async t => { | ||
const opts = options(); | ||
const vat = xsnap(opts); | ||
t.teardown(() => vat.terminate()); | ||
const result = await vat.evaluate(` | ||
let m = new Map(); | ||
let s1 = new Set(); | ||
for (ix = 0; ix < 20000; ix++) { | ||
m.set(ix, 'garbage'); | ||
s1.add(ix); | ||
} | ||
for (ix = 0; ix < 20000; ix++) { | ||
m.delete(ix); | ||
s1.delete(ix); | ||
} | ||
`); | ||
const { | ||
meterUsage: { meterType, ...meters }, | ||
} = result; | ||
t.log(meters); | ||
const { entries, fromEntries } = Object; | ||
t.deepEqual( | ||
{ | ||
compute: 'number', | ||
allocate: 'number', | ||
allocateChunksCalls: 'number', | ||
allocateSlotsCalls: 'number', | ||
garbageCollectionCount: 'number', | ||
mapSetAddCount: 'number', | ||
mapSetRemoveCount: 'number', | ||
maxBucketSize: 'number', | ||
}, | ||
fromEntries(entries(meters).map(([p, v]) => [p, typeof v])), | ||
); | ||
t.is(meterType, 'xs-meter-6'); | ||
}); | ||
|
||
test('high resolution timer', async t => { | ||
const opts = options(); | ||
const vat = xsnap(opts); | ||
t.teardown(() => vat.terminate()); | ||
await vat.evaluate(` | ||
const send = it => issueCommand(ArrayBuffer.fromString(JSON.stringify(it))); | ||
const t = performance.now(); | ||
send(t); | ||
`); | ||
const [milliseconds] = opts.messages.map(JSON.parse); | ||
t.log({ milliseconds, date: new Date(milliseconds) }); | ||
t.is('number', typeof milliseconds); | ||
}); |
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