FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
node/benchmark/vm/compile-script-in-isolate-cache.js at main · fetchapi/node · GitHub
fetchapi
/
node
Public
forked from
nodejs/node
Notifications
You must be signed in to change notification settings
Fork
1
Star
0
Code
Pull requests
1
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
node
/
benchmark
/
vm
/
compile-script-in-isolate-cache.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
35 lines (31 loc) · 1020 Bytes
Breadcrumbs
node
/
benchmark
/
vm
/
compile-script-in-isolate-cache.js
Copy path
File metadata and controls
35 lines (31 loc) · 1020 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
34
35
'use strict'
;
// This benchmarks compiling scripts that hit the in-isolate compilation
// cache (by having the same source).
const
common
=
require
(
'../common.js'
)
;
const
fs
=
require
(
'fs'
)
;
const
vm
=
require
(
'vm'
)
;
const
fixtures
=
require
(
'../../test/common/fixtures.js'
)
;
const
scriptPath
=
fixtures
.
path
(
'snapshot'
,
'typescript.js'
)
;
const
bench
=
common
.
createBenchmark
(
main
,
{
type
:
[
'with-dynamic-import-callback'
,
'without-dynamic-import-callback'
]
,
n
:
[
100
]
,
}
)
;
const
scriptSource
=
fs
.
readFileSync
(
scriptPath
,
'utf8'
)
;
function
main
(
{
n
,
type
}
)
{
let
script
;
bench
.
start
(
)
;
const
options
=
{
}
;
switch
(
type
)
{
case
'with-dynamic-import-callback'
:
// Use a dummy callback for now until we really need to benchmark it.
options
.
importModuleDynamically
=
async
(
)
=>
{
}
;
break
;
case
'without-dynamic-import-callback'
:
break
;
}
for
(
let
i
=
0
;
i
<
n
;
i
++
)
{
script
=
new
vm
.
Script
(
scriptSource
,
options
)
;
}
bench
.
end
(
n
)
;
script
.
runInThisContext
(
)
;
}
Back
|
FazBrowse Home
|
New Git URL