FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
msgpack-javascript/benchmark/encode-string.ts at main · msgpack/msgpack-javascript · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
msgpack
/
msgpack-javascript
Public
Notifications
You must be signed in to change notification settings
Fork
180
Star
1.6k
Code
Issues
18
Pull requests
6
Discussions
Actions
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
msgpack-javascript
/
benchmark
/
encode-string.ts
Copy path
More file actions
More file actions
Latest commit
History
History
History
33 lines (25 loc) · 831 Bytes
Breadcrumbs
msgpack-javascript
/
benchmark
/
encode-string.ts
Copy path
File metadata and controls
33 lines (25 loc) · 831 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* eslint-disable no-console */
import
{
utf8EncodeJs
,
utf8Count
,
utf8EncodeTE
}
from
"../src/utils/utf8.ts"
;
//
@ts
-ignore
import
Benchmark
from
"benchmark"
;
for
(
const
baseStr
of
[
"A"
,
"あ"
,
"🌏"
]
)
{
const
dataSet
=
[
10
,
30
,
50
,
100
]
.
map
(
(
n
)
=>
{
return
baseStr
.
repeat
(
n
)
;
}
)
;
for
(
const
str
of
dataSet
)
{
const
byteLength
=
utf8Count
(
str
)
;
const
buffer
=
new
Uint8Array
(
byteLength
)
;
console
.
log
(
`\n## string "
${
baseStr
}
" (strLength=
${
str
.
length
}
, byteLength=
${
byteLength
}
)\n`
)
;
const
suite
=
new
Benchmark
.
Suite
(
)
;
suite
.
add
(
"utf8EncodeJs"
,
(
)
=>
{
utf8EncodeJs
(
str
,
buffer
,
0
)
;
}
)
;
suite
.
add
(
"utf8DecodeTE"
,
(
)
=>
{
utf8EncodeTE
(
str
,
buffer
,
0
)
;
}
)
;
suite
.
on
(
"cycle"
,
(
event
:
any
)
=>
{
console
.
log
(
String
(
event
.
target
)
)
;
}
)
;
suite
.
run
(
)
;
}
}
Back
|
FazBrowse Home
|
New Git URL