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
0d5db91c
Commit
0d5db91c
authored
Nov 10, 2019
by
nagayama15
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add zlib benchmark
parent
d909f238
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
8 deletions
+16
-8
benchmark.js
example/zlib-wasm/benchmark.js
+10
-0
zlib.js
example/zlib-wasm/zlib.js
+6
-8
No files found.
example/zlib-wasm/benchmark.js
0 → 100644
View file @
0d5db91c
(
async
function
()
{
const
Zlib
=
await
require
(
'./zlib'
).
initialize
(
'./zlib-sample.wasm'
);
const
rawData
=
Buffer
.
from
([...
Array
(
10000
).
keys
()]);
const
compressedData
=
Zlib
.
deflate
(
rawData
);
const
uncompressedData
=
Zlib
.
inflate
(
compressedData
);
console
.
log
(
uncompressedData
.
equals
(
rawData
));
}());
example/zlib-wasm/
index
.js
→
example/zlib-wasm/
zlib
.js
View file @
0d5db91c
"use strict"
;
"use strict"
;
const
fs
=
require
(
"fs"
);
const
fs
=
require
(
"fs"
);
const
buff
=
fs
.
readFileSync
(
"build/zlib-sample.wasm"
);
let
ret
;
module
.
exports
.
initialize
=
async
()
=>
{
module
.
exports
.
initialize
=
async
(
wasm_path
)
=>
{
if
(
ret
)
return
ret
;
const
buff
=
fs
.
readFileSync
(
wasm_path
)
;
const
COMPRESSION_LEVEL
=
6
;
const
COMPRESSION_LEVEL
=
6
;
const
NO_ZLIB_HEADER
=
-
1
;
const
NO_ZLIB_HEADER
=
-
1
;
...
@@ -62,7 +60,7 @@ module.exports.initialize = async () => {
...
@@ -62,7 +60,7 @@ module.exports.initialize = async () => {
}
}
getBuffer
()
{
getBuffer
()
{
return
new
Buffer
(
this
.
buff
.
buffer
,
0
,
this
.
offset
);
return
Buffer
.
from
(
this
.
buff
.
buffer
,
0
,
this
.
offset
);
}
}
}
}
...
@@ -97,11 +95,11 @@ module.exports.initialize = async () => {
...
@@ -97,11 +95,11 @@ module.exports.initialize = async () => {
}
}
getBuffer
()
{
getBuffer
()
{
return
new
Buffer
(
this
.
buff
.
buffer
,
0
,
this
.
offset
);
return
Buffer
.
from
(
this
.
buff
.
buffer
,
0
,
this
.
offset
);
}
}
}
}
ret
=
{
const
ret
=
{
inflate
(
rawDeflateBuffer
)
{
inflate
(
rawDeflateBuffer
)
{
const
rawInf
=
new
RawInf
();
const
rawInf
=
new
RawInf
();
for
(
let
offset
=
0
;
offset
<
rawDeflateBuffer
.
length
;
offset
+=
CHUNK_SIZE
)
{
for
(
let
offset
=
0
;
offset
<
rawDeflateBuffer
.
length
;
offset
+=
CHUNK_SIZE
)
{
...
...
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