Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
chrome-benchmarker
Advanced tools
Benchmark execution time and memory usage using the Chrome Debugger Protocol
Benchmark memory allocation and execution time of browser code using the Chrome Debugger Protocol.
Useful when trying to write garbage free Javascript.
$ npm install chrome-benchmarker
Write a JavaScript file with the benchmark:
console.timeStamp('startTest'); //Call before benchmark code
doSomeStuff();
console.timeStamp('endTest'); //Call after benchmark code
$ chrome-benchmarker benchmark.js
This will start an HTTP server to serve the code in benchmark.js, launch Chrome, connect to the Chrome remote debugging interface, collect and process the Timeline data and print the total allocated memory and execution time.
benchmarker = require('chrome-benchmarker')
benchmarker.js('benchmark.js', function(err, result) {
// result = { memory, time }
});
It is possible to run benchmarks which require multiple scripts or other HTML code by using an HTML file:
<html>
<body>
<div id="someDomStuff"></div>
<script type="text/javascript" src="someDependency.js"></script>
<script type="text/javascript">
console.timeStamp('startTest'); //Call before benchmark code
doSomeStuff();
console.timeStamp('endTest'); //Call after benchmark code
</script>
</body>
</html>
$ chrome-benchmarker benchmark.html
In Node:
benchmarker.html('benchmark.html', callback)
If the required file(s) are already being served, one can simply run the benchmark from their URL:
$ chrome-benchmarker http://localhost:3000/benchmark.html
$ chrome-benchmarker http://localhost:3000/benchmark.js
In Node:
benchmarker.url('http://localhost:3000/benchmark.html', callback)
benchmarker.url('http://localhost:3000/benchmark.js', callback)
javascriptFilePath
is a path to a JavaScript file with the code to be benchmarked. The code should call console.timeStamp('startTest')
and console.timeStamp('endTest')
.
options
is an object with the following optional properties:
port
: Webserver port. Defaults to 8666
.host
: Webserver host. Defaults to localhost
.debuggingPort
: Remote Debugging Protocol port. Defaults to 9222
.callback
gets the following arguments:
err
: a Error object indicating the success status.result
: an object { memory, time }
.Similar to js()
, but receiving a stream instead of a file path
Similar to js()
, but receiving source code instead of a file path
mainHtmlFilePath
is a path to an HTML file with the code to be benchmarked. This file may load other files. The code it executes should call console.timeStamp('startTest')
and console.timeStamp('endTest')
.
options
is an object with the following optional properties:
basePath
: Webserver root path. Defaults to path.dirname(mainHtmlFilePath)
.port
: Webserver port. Defaults to 8666
.host
: Webserver host. Defaults to localhost
.debuggingPort
: Remote Debugging Protocol port. Defaults to 9222
.callback
gets the following arguments:
err
: a Error object indicating the success status.result
: an object { memory, time }
.url
is a URL to be benchmarked. The code it executes should call console.timeStamp('startTest')
and console.timeStamp('endTest')
.
options
is an object with the following optional properties:
debuggingPort
: Remote Debugging Protocol port. Defaults to 9222
.callback
gets the following arguments:
err
: a Error object indicating the success status.result
: an object { memory, time }
.chrome-benchmarker.js target --json --useFun <url|js|html> --debuggingPort <port> --port <port> --host <host> --basePath <path>
All arguments except target
are optional.
If target
is stdinJs
, the Javascript source for the test will be read from the standard input.
https://developer.chrome.com/devtools/docs/debugger-protocol
https://developer.chrome.com/devtools/docs/protocol/1.1/index
http://buildnewgames.com/garbage-collector-friendly-code/
Sometimes there is a ECONNREFUSED
error
FAQs
Benchmark execution time and memory usage using the Chrome Debugger Protocol
We found that chrome-benchmarker demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.