Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
wasm-watermarker
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nagayama15
wasm-watermarker
Commits
19c9a04c
Verified
Commit
19c9a04c
authored
Jan 12, 2020
by
nagayama15
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update the benchmark script
parent
22e43969
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
32 deletions
+21
-32
benchmark.js
example/ammo.js/benchmark.js
+7
-17
benchmark.js
example/zlib-wasm/benchmark.js
+14
-15
No files found.
example/ammo.js/benchmark.js
View file @
19c9a04c
require
(
"./testutils"
);
const
stress
=
require
(
"./stress"
);
const
WARM
=
3
;
const
N
=
10
+
WARM
;
(
async
()
=>
{
const
runBench
=
dir
=>
{
const
Ammo
=
require
(
`./
${
dir
}
/ammo.wasm`
);
return
new
Promise
(
resolve
=>
{
console
.
error
(
`
${
dir
}
`
);
// Wrap `Ammo()` by real `Promise` object because it returns just Promise-like object
// and awaiting it acts buggy.
Ammo
().
then
(
Ammo
=>
{
const
durs
=
[];
for
(
let
i
=
0
;
i
<
N
;
i
++
)
{
const
dur
=
stress
(
Ammo
);
durs
.
push
(
dur
);
console
.
error
(
dur
);
}
resolve
({
dir
,
durs
});
const
dur
=
stress
(
Ammo
);
resolve
(
dur
);
});
});
};
...
...
@@ -41,10 +31,10 @@ const N = 10 + WARM;
"dist/ammo-3-fe8191b3"
];
const
results
=
[];
for
(
wasm
of
wasms
)
{
results
.
push
(
await
runBench
(
wasm
));
const
row
=
[];
const
keys
=
[...
wasms
.
keys
()].
sort
(()
=>
Math
.
random
()
-
0.5
);
for
(
const
i
of
keys
)
{
row
[
i
]
=
await
runBench
(
wasms
[
i
]);
}
console
.
log
(
JSON
.
stringify
(
results
));
console
.
log
(
row
.
join
(
"
\
t"
));
})();
example/zlib-wasm/benchmark.js
View file @
19c9a04c
const
Crypto
=
require
(
"crypto"
);
const
assert
=
require
(
"assert"
);
const
size
=
1
_000_000
;
const
size
=
1
0
_000_000
;
const
rawData
=
Crypto
.
randomBytes
(
size
);
(
async
function
()
{
...
...
@@ -49,19 +49,18 @@ const rawData = Crypto.randomBytes(size);
console
.
log
(
`deflated size:
${
compressed
.
length
}
bytes`
);
console
.
log
(
`compression rate:
${(
compressionRate
*
100
).
toFixed
(
1
)}
%`
);
libs
.
forEach
((
Zlib
,
i
)
=>
{
// Warming up
console
.
time
(
`Warm -
${
libPaths
[
i
]}
`
);
for
(
let
i
=
0
;
i
<
10
;
i
++
)
{
Zlib
.
deflate
(
rawData
);
}
console
.
timeEnd
(
`Warm -
${
libPaths
[
i
]}
`
);
console
.
log
(
libPaths
.
join
(
"
\
t"
));
// Benchmark
console
.
time
(
`Benchmark -
${
libPaths
[
i
]}
`
);
for
(
let
i
=
0
;
i
<
100
;
i
++
)
{
Zlib
.
deflate
(
rawData
);
}
console
.
timeEnd
(
`Benchmark -
${
libPaths
[
i
]}
`
);
});
for
(
let
i
=
0
;
i
<
100
;
i
++
)
{
const
keys
=
[...
libs
.
keys
()].
sort
(()
=>
Math
.
random
()
-
0.5
);
const
row
=
[];
keys
.
forEach
(
i
=>
{
const
start
=
Date
.
now
();
libs
[
i
].
deflate
(
rawData
);
const
end
=
Date
.
now
();
row
[
i
]
=
end
-
start
;
});
console
.
log
(
row
.
join
(
"
\
t"
));
}
})();
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment