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
Show 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"
);
require
(
"./testutils"
);
const
stress
=
require
(
"./stress"
);
const
stress
=
require
(
"./stress"
);
const
WARM
=
3
;
const
N
=
10
+
WARM
;
(
async
()
=>
{
(
async
()
=>
{
const
runBench
=
dir
=>
{
const
runBench
=
dir
=>
{
const
Ammo
=
require
(
`./
${
dir
}
/ammo.wasm`
);
const
Ammo
=
require
(
`./
${
dir
}
/ammo.wasm`
);
return
new
Promise
(
resolve
=>
{
return
new
Promise
(
resolve
=>
{
console
.
error
(
`
${
dir
}
`
);
// Wrap `Ammo()` by real `Promise` object because it returns just Promise-like object
// Wrap `Ammo()` by real `Promise` object because it returns just Promise-like object
// and awaiting it acts buggy.
// and awaiting it acts buggy.
Ammo
().
then
(
Ammo
=>
{
Ammo
().
then
(
Ammo
=>
{
const
durs
=
[];
for
(
let
i
=
0
;
i
<
N
;
i
++
)
{
const
dur
=
stress
(
Ammo
);
const
dur
=
stress
(
Ammo
);
durs
.
push
(
dur
);
resolve
(
dur
);
console
.
error
(
dur
);
}
resolve
({
dir
,
durs
});
});
});
});
});
};
};
...
@@ -41,10 +31,10 @@ const N = 10 + WARM;
...
@@ -41,10 +31,10 @@ const N = 10 + WARM;
"dist/ammo-3-fe8191b3"
"dist/ammo-3-fe8191b3"
];
];
const
results
=
[];
const
row
=
[];
for
(
wasm
of
wasms
)
{
const
keys
=
[...
wasms
.
keys
()].
sort
(()
=>
Math
.
random
()
-
0.5
);
results
.
push
(
await
runBench
(
wasm
));
for
(
const
i
of
keys
)
{
row
[
i
]
=
await
runBench
(
wasms
[
i
]);
}
}
console
.
log
(
row
.
join
(
"
\
t"
));
console
.
log
(
JSON
.
stringify
(
results
));
})();
})();
example/zlib-wasm/benchmark.js
View file @
19c9a04c
const
Crypto
=
require
(
"crypto"
);
const
Crypto
=
require
(
"crypto"
);
const
assert
=
require
(
"assert"
);
const
assert
=
require
(
"assert"
);
const
size
=
1
_000_000
;
const
size
=
1
0
_000_000
;
const
rawData
=
Crypto
.
randomBytes
(
size
);
const
rawData
=
Crypto
.
randomBytes
(
size
);
(
async
function
()
{
(
async
function
()
{
...
@@ -49,19 +49,18 @@ const rawData = Crypto.randomBytes(size);
...
@@ -49,19 +49,18 @@ const rawData = Crypto.randomBytes(size);
console
.
log
(
`deflated size:
${
compressed
.
length
}
bytes`
);
console
.
log
(
`deflated size:
${
compressed
.
length
}
bytes`
);
console
.
log
(
`compression rate:
${(
compressionRate
*
100
).
toFixed
(
1
)}
%`
);
console
.
log
(
`compression rate:
${(
compressionRate
*
100
).
toFixed
(
1
)}
%`
);
libs
.
forEach
((
Zlib
,
i
)
=>
{
console
.
log
(
libPaths
.
join
(
"
\
t"
));
// Warming up
console
.
time
(
`Warm -
${
libPaths
[
i
]}
`
);
for
(
let
i
=
0
;
i
<
10
;
i
++
)
{
Zlib
.
deflate
(
rawData
);
}
console
.
timeEnd
(
`Warm -
${
libPaths
[
i
]}
`
);
// Benchmark
console
.
time
(
`Benchmark -
${
libPaths
[
i
]}
`
);
for
(
let
i
=
0
;
i
<
100
;
i
++
)
{
for
(
let
i
=
0
;
i
<
100
;
i
++
)
{
Zlib
.
deflate
(
rawData
);
const
keys
=
[...
libs
.
keys
()].
sort
(()
=>
Math
.
random
()
-
0.5
);
}
const
row
=
[];
console
.
timeEnd
(
`Benchmark -
${
libPaths
[
i
]}
`
);
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