Comparing version 2.3.1 to 2.4.0
@@ -7,3 +7,12 @@ var fs = require('fs') | ||
module.exports = function (svg, opts, next, done) { | ||
var dir = opts.dir || '.' | ||
debug('checking for convert binary') | ||
if (!opts.preview) { | ||
write(svg, dir) | ||
next() | ||
done() | ||
return | ||
} | ||
which('convert', function (err, path) { | ||
@@ -17,5 +26,4 @@ if (err) { | ||
var dir = opts.dir || '.' | ||
debug('writing svg') | ||
fs.writeFileSync(dir + '/flamegraph.svg', svg) | ||
write(svg, dir) | ||
var background = 'black' | ||
@@ -34,2 +42,8 @@ var args = ['-background', background, '-trim', '-resize', | ||
}) | ||
function write (svg, dir) { | ||
debug('writing svg') | ||
svg = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n' + svg | ||
fs.writeFileSync(dir + '/flamegraph.svg', svg) | ||
} | ||
} |
15
gen.js
@@ -31,3 +31,3 @@ /* global innerWidth d3*/ | ||
if (!browser && !opts.preview) { | ||
if (!browser && !opts.svg) { | ||
var f = '<meta charset="utf-8">' + | ||
@@ -59,3 +59,3 @@ '<h1 style="color: rgb(68, 68, 68);">' + opts.title + '</h1>' + | ||
var flamegraph = flamer() | ||
var flamegraph = flamer(opts) | ||
.width(width) | ||
@@ -375,3 +375,3 @@ .height(height) | ||
if (browser || opts.preview) { | ||
if (browser || opts.svg) { | ||
d3.select(chart).datum(stacks).call(flamegraph) | ||
@@ -399,4 +399,11 @@ var svg = chart.querySelector('svg') | ||
if (opts.preview) { | ||
if (opts.svg) { | ||
svg.setAttribute('width', +svg.getAttribute('width') * 2) | ||
svg.setAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/') | ||
svg.setAttribute('xmlns:cc', 'http://creativecommons.org/ns#') | ||
svg.setAttribute('xmlns:rdf', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#') | ||
svg.setAttribute('xmlns:svg', 'http://www.w3.org/2000/svg') | ||
svg.setAttribute('xmlns', 'http://www.w3.org/2000/svg') | ||
svg.setAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink') | ||
svg.setAttribute('version', '1.0') | ||
next = next || function () {} | ||
@@ -403,0 +410,0 @@ require('./flame-' + 'image')(chart.innerHTML, {dir: dir}, next, function () { |
@@ -78,6 +78,6 @@ var fs = require('fs') | ||
var args = [ | ||
args = Object.assign([ | ||
'--perf-basic-prof', | ||
'-r', path.join(__dirname, 'soft-exit') | ||
].concat(args.node) | ||
].concat(args.node), args) | ||
@@ -344,2 +344,5 @@ var proc = spawn(node, args, { | ||
var preview = args.preview || args.p | ||
if (preview) args.svg = true | ||
var svg = args.svg | ||
debug('begin rendering') | ||
@@ -374,2 +377,3 @@ return convert(function (err, json) { | ||
dir: folder, | ||
svg: svg, | ||
preview: preview, | ||
@@ -376,0 +380,0 @@ exclude: exclude, |
{ | ||
"name": "0x", | ||
"version": "2.3.1", | ||
"version": "2.4.0", | ||
"description": "🔥 single-command flamegraph profiling 🔥", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -141,2 +141,13 @@ # <img alt=0x src=0x-logo.png width=350> | ||
### --output-dir | -o | ||
Specify artifact output directory | ||
Default: '${process.cwd()}/profile-${PID}(-${Date.now()})?' | ||
### --svg | ||
Generates an `flamegraph.svg` file in the artifact output directory, | ||
in addition to the `flamegraph.html` file. | ||
### --preview | ||
@@ -261,4 +272,4 @@ | ||
A profile folder will be created and named after the PID, e.g. | ||
`profile-3866`. | ||
By default, a profile folder will be created and named after the PID, e.g. | ||
`profile-3866` (we can set this name manually using the `--output-dir` flag). | ||
@@ -265,0 +276,0 @@ The Profile Folder can contain the following files |
@@ -14,2 +14,5 @@ | ||
--svg Generates an `flamegraph.svg` file in the artifact | ||
output directory, in addition to the `flamegraph.html` file. | ||
--preview | -p Generates an SVG file, prerenders SVG inside HTML | ||
@@ -16,0 +19,0 @@ and outputs a PNG to the terminal (if possible) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
69578
1439
349