Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
heimdalljs
Advanced tools
HeimdallJS is a lightweight performance monitoring library for JavaScript applications. It allows developers to track and measure the performance of their code by creating performance metrics and visualizing them. This can be particularly useful for identifying bottlenecks and optimizing the performance of web applications.
Creating a Monitor
This feature allows you to create a performance monitor that tracks the execution time of a specific block of code. You start the monitor before the code block and stop it after the code block.
const heimdall = require('heimdalljs');
const monitor = heimdall.start('my-monitor');
// Your code here
monitor.stop();
Tracking Performance Metrics
This feature allows you to track specific performance metrics by starting and stopping named metrics. You can then retrieve and log the statistics for these metrics.
const heimdall = require('heimdalljs');
heimdall.start('my-metric');
// Your code here
heimdall.stop('my-metric');
const stats = heimdall.statsFor('my-metric');
console.log(stats);
Visualizing Performance Data
This feature allows you to visualize the performance data collected by HeimdallJS. You can convert the performance data into a JSON format and log it for further analysis.
const heimdall = require('heimdalljs');
const monitor = heimdall.start('my-monitor');
// Your code here
monitor.stop();
const tree = heimdall.toJSON();
console.log(JSON.stringify(tree, null, 2));
The 'performance-now' package provides a high-resolution timer for measuring performance in JavaScript applications. It is simpler and more lightweight compared to HeimdallJS, focusing solely on providing precise timestamps.
The 'statsd' package is a network daemon that listens for statistics, like counters and timers, sent over UDP or TCP and sends aggregates to one or more pluggable backend services. It is more comprehensive and can be used for a broader range of performance monitoring tasks compared to HeimdallJS.
The 'node-perf' package is a performance monitoring tool for Node.js applications. It provides similar functionality to HeimdallJS, such as tracking execution time and performance metrics, but is specifically designed for Node.js environments.
A blazingly fast performance stat monitoring and collection library for node or the browser.
npm install heimdalljs
Heimdall allows for 2 forms of stat collection: counter based and time based.
The overhead of time based stat collection is the cost of allocating a
tiny TypedArray
, a four element Array
, and performance.now()
. On
Desktop Chrome on a 2015 era MacBook Pro this amounts to roughly 200
nano seconds. You can easily run the benchmarks on devices you care about
to see what the cost will be for you.
The overhead of counter based collection is the cost of a method call with two bitwise operations and an integer increment. An occasional Uint32Array allocation is thrown in when more space is needed. The cost here is pragmatically negligible, and counters are ideal for situations in which the overhead of a timer is enough to significantly alter stats.
instantiate
const heimdall = new Heimdall();
start timing something
const token = heimdall.start('<label>');
stop timing something
heimdall.stop(token);
register
let tokens = heimdall.registerMonitor('<name>', ...labels);
Example:
let [a, b, c] = heimdall.registerMonitor('<name>', 'foo', 'bar', 'baz');
using
heimdall.increment(a);
heimdall.annotate(<annotation>);
configFor toJSON
For the documentation for HeimdallTree
see .
If desired, heimdall can be stripped from production builds using this plugin for Babel5 or this plugin for Babel6.
Heimdall tracks a graph of timing and domain-specific stats for performance. Stat collection and monitoring is separated from graph construction to provide control over context detail. Users can create fewer nodes to have reduced performance overhead, or create more nodes to provide more detail.
The graph obviously needs to be global. This is not a problem in the browser,
but in node we may have multiple different versions of heimdalljs loaded at
once. Each one will have its own Heimdall
instance, but will use the same
session, saved on process
. This means that the session will have a
heterogeneous graph of HeimdallNode
s. For this reason, versions of heimdalljs
that change Session
, or the APIs of HeimdallNode
or Cookie
will use a
different property to store their session (process._heimdall_session_<n>
). It
is quite easy for this to result in lost detail & lost stats, although it is
also easy to detect this situation and issue a warning.
FAQs
Structured instrumentation library
The npm package heimdalljs receives a total of 252,310 weekly downloads. As such, heimdalljs popularity was classified as popular.
We found that heimdalljs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 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
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.