Created
December 25, 2016 19:27
-
-
Save mooyoul/dcbc852df8f3b0ceccdbef0330b58970 to your computer and use it in GitHub Desktop.
VM `timeout` issue example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const | |
vm = require('vm'), | |
sandbox = { | |
current: -1 | |
}; | |
console.time('vm-normal'); | |
vm.createContext(sandbox); | |
for (let i = 0 ; i < 100000 ; i++) { | |
vm.runInContext(`current = ${i};`, sandbox, { | |
displayErrors: false | |
}); | |
} | |
console.timeEnd('vm-normal'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const | |
vm = require('vm'), | |
sandbox = { | |
current: -1 | |
}; | |
console.time('vm-with-timeout'); | |
vm.createContext(sandbox); | |
for (let i = 0 ; i < 100000 ; i++) { | |
vm.runInContext(`current = ${i};`, sandbox, { | |
displayErrors: false, | |
timeout: 1000 | |
}); | |
} | |
console.timeEnd('vm-with-timeout'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment