New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cpuprofilify

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cpuprofilify - npm Package Compare versions

Comparing version 0.2.4 to 0.3.0

lib/remove-optimization-info.js

7

bin/cpuprofilify-usage.txt

@@ -8,3 +8,2 @@ usage: cat trace.txt | cpuprofilify <options> > my.cpuprofile

--shortStack , --noshortStack stacks that have only one line are ignored unless this flag is set (default: false)
--unresolveds , --nounresolveds unresolved addresses like `0x1a23c` are filtered from the trace unless this flag is set (default: false)

@@ -15,3 +14,6 @@ --sysinternals , --nosysinternals sysinternals like `__lib_c_start...` are filtered from the trace unless this flag is set (default: false)

--shortStack , --noshortStack stacks that have only one line are ignored unless this flag is set (default: false)
--optimizationinfo, --nooptimizationinfo JS optimization info is removed unless this flag is set (default: false)
--type type of input `perf|dtrace|instruments`. If not supplied it will be detected.

@@ -22,3 +24,4 @@ --help print this help

Generate cpuprofile from DTrace data with default options
Generate cpuprofile from DTrace data with default options
using higher switchrate in order to deal with large amount of data being emitted

@@ -25,0 +28,0 @@ sudo profile_1ms.d -c <command> | cpuprofilify > out.cpuprofile

@@ -46,2 +46,3 @@ 'use strict';

* @param {Boolean} opts.shortStack stacks that have only one line are ignored unless this flag is set
* @param {Boolean} opts.optimizationinfo JS optimization info is removed unless this flag is set (default: false)
* @param {Boolean} opts.unresolveds unresolved addresses like `0x1a23c` are filtered from the trace unless this flag is set (default: false)

@@ -48,0 +49,0 @@ * @param {Boolean} opts.sysinternals sysinternals like `__lib_c_start...` are filtered from the trace unless this flag is set (default: false)

@@ -47,5 +47,2 @@ 'use strict';

function inspect(obj, depth) {
console.error(require('util').inspect(obj, false, depth || 5, true));
}
proto._parseTraceInfo = function _parseTraceInfo(line, isStart) {

@@ -68,7 +65,9 @@ var parts = line.split(' ');

proto._normalizeFrame = function _normalizeFrame(frame) {
return frame
.trim()
.replace(this._frameAddressRegex, '')
.replace(this._frameProcessRegex, '')
.replace(this._frameJSAddressRegex, '')
return this.removeOptimizationInfo(
frame
.trim()
.replace(this._frameAddressRegex, '')
.replace(this._frameProcessRegex, '')
.replace(this._frameJSAddressRegex, '')
)
}

@@ -85,3 +84,3 @@

proto._frameAddressRegex = /\+0x[0-9a-fA-F]+$/
proto._frameJSAddressRegex = /0x[0-9a-fA-F]+( LazyCompile:| Function:){0,1}/
proto._frameJSAddressRegex = /0x[0-9a-fA-F]+( LazyCompile:| Function:| Script:){0,1}/
proto.type = 'dtrace';

@@ -88,0 +87,0 @@

'use strict';
var cpuprofile = require('./cpuprofile')
, traceUtil = require('./trace-util')
, Converter = require('./converter').proto
var cpuprofile = require('./cpuprofile')
, traceUtil = require('./trace-util')
, roi = require('./remove-optimization-info')
, Converter = require('./converter').proto
, headerRegex = /^Running Time, *Self,.*, *Symbol Name/

@@ -33,2 +34,5 @@

this._samples = [];
this._optimizationinfo = opts.optimizationinfo;
this._head = cpuprofile.createHead(this._process, this._id++);

@@ -49,3 +53,4 @@ }

var node = cpuprofile.createNode(nextId, stackFrame, { functionName: stackFrame });
var node = cpuprofile
.createNode(nextId, stackFrame, { functionName: this.adjustFunctionName(stackFrame) });
parent.children.push(node);

@@ -96,2 +101,6 @@ return node;

proto.adjustFunctionName = function adjustFunctionName(name) {
return this._optimizationinfo ? name : roi(name);
}
proto.cpuprofile = function cpuprofile() {

@@ -98,0 +107,0 @@ return {

@@ -15,3 +15,3 @@ 'use strict';

proto._frameRegex = /^\w+\s+(?:LazyCompile:|Function:){0,1}(.+?)\W\(\S+\)$/;
proto._frameRegex = /^\w+\s+(?:LazyCompile:|Function:|Script:){0,1}(.+?)\W\(\S+\)$/;
proto._framePartsRegex = /^(.+?)([\S\.]+):(\d+)$/;

@@ -29,5 +29,7 @@

proto._normalizeFrame = function _normalizeFrame(frame) {
return frame
.trim()
.replace(this._frameRegex, '$1')
return this.removeOptimizationInfo(
frame
.trim()
.replace(this._frameRegex, '$1')
)
}

@@ -34,0 +36,0 @@

@@ -5,2 +5,3 @@ 'use strict';

, traceUtil = require('./trace-util')
, roi = require('./remove-optimization-info')

@@ -29,2 +30,3 @@ function Converter(trace, traceStart, opts) {

this._optimizationinfo = opts.optimizationinfo;
this._shortStacks = opts.shortStacks;

@@ -120,2 +122,6 @@ }

proto.removeOptimizationInfo = function removeOptimizationInfo(name) {
return this._optimizationinfo ? name : roi(name);
}
proto.cpuprofile = function cpuprofile() {

@@ -122,0 +128,0 @@ return {

{
"name": "cpuprofilify",
"version": "0.2.4",
"version": "0.3.0",
"description": "Converts output of various profiling/sampling tools to the .cpuprofile format so it can be loaded into Chrome DevTools.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -44,4 +44,4 @@ # cpuprofilify [![build status](https://secure.travis-ci.org/thlorenz/cpuprofilify.png?branch=master)](http://travis-ci.org/thlorenz/cpuprofilify)

# In Terminal A
➝ sudo profile_1ms.d -c 'node --perf-basic-prof example/fibonacci' | cpuprofilify > /tmp/example.cpuprofile
➝ sudo profile_1ms.d -c 'node --perf-basic-prof example/fibonacci' | \
cpuprofilify > /tmp/example.cpuprofile
pid <process-pid>

@@ -76,3 +76,2 @@ HTTP server listening on port 8000

--shortStack , --noshortStack stacks that have only one line are ignored unless this flag is set (default: false)
--unresolveds , --nounresolveds unresolved addresses like `0x1a23c` are filtered from the trace unless this flag is set (default: false)

@@ -83,2 +82,6 @@ --sysinternals , --nosysinternals sysinternals like `__lib_c_start...` are filtered from the trace unless this flag is set (default: false)

--shortStack , --noshortStack stacks that have only one line are ignored unless this flag is set (default: false)
--optimizationinfo, --nooptimizationinfo JS optimization info is removed unless this flag is set (default: false)
--type type of input `perf|dtrace|instruments`. If not supplied it will be detected.

@@ -89,5 +92,6 @@ --help print this help

Generate cpuprofile from DTrace data with default options
Generate cpuprofile from DTrace data with default options
using higher switchrate in order to deal with large amount of data being emitted
sudo profile_1ms.d -c <command> | cpuprofilify > out.cpuprofile
sudo profile_1ms.d -x switchrate=1000hz -c <command> | cpuprofilify > out.cpuprofile

@@ -215,2 +219,9 @@ Generate cpuprofile from DTrace data with default options keeping v8 internals

<tr>
<td class="name"><code>optimizationinfo</code></td>
<td class="type">
<span class="param-type">Boolean</span>
</td>
<td class="description last"><p>JS optimization info is removed unless this flag is set (default: false)</p></td>
</tr>
<tr>
<td class="name"><code>unresolveds</code></td>

@@ -217,0 +228,0 @@ <td class="type">

@@ -73,2 +73,36 @@ 'use strict';

test('\nwhen converting a DTrace stack containing C++ and resolved JavaScript with the default settings', function (t) {
var opts = {
fns: 22,
hits: 1,
id: 20,
fn: '~*ArrayConcatJS',
url: 'native array.js',
names:
[ 'iojs',
'uv_run',
'uv__io_poll',
'uv__stream_io',
'node::StreamWrapCallbacks::DoRead(uv_stream_s*, long, uv_buf_t const*, uv_handle_type)',
'node::AsyncWrap::MakeCallback(v8::Handle<v8::Function>, int, v8::Handle<v8::Value>*)',
'~*onread',
'~*Readable.push',
'~*readableAddChunk',
'~*emit',
'~*socketOnData',
'node::Parser::Execute(v8::FunctionCallbackInfo<v8::Value> const&)',
'http_parser_execute',
'node::Parser::on_headers_complete_()',
'~*parserOnHeadersComplete',
'~*parserOnIncoming',
'~*emit',
'~*onRequest',
'~*cal_arrayConcat',
'~*reduce',
'~*toFib',
'~*ArrayConcatJS' ] }
check(t, stack1, null, opts)
})
test('\nwhen converting a DTrace stack containing C++ and resolved JavaScript keeping optimization info', function (t) {
var opts = {

@@ -104,3 +138,3 @@ fns : 22

check(t, stack1, null, opts)
check(t, stack1, { optimizationinfo: true }, opts)
})

@@ -110,9 +144,9 @@

var opts = {
fns : 48,
hits : 1,
id : 46,
fn : 'v8::internal::Runtime_ArrayConcat(int, v8::internal::Object**, v8::internal::Isolate*)',
url : '',
names: [
'iojs',
fns: 48,
hits: 1,
id: 46,
fn: 'v8::internal::Runtime_ArrayConcat(int, v8::internal::Object**, v8::internal::Isolate*)',
url: '',
names:
[ 'iojs',
'start',

@@ -130,9 +164,9 @@ 'node::Start(int, char**)',

' Builtin:ArgumentsAdaptorTrampoline',
'~onread',
'~*onread',
' Builtin:ArgumentsAdaptorTrampoline',
'~Readable.push',
'~readableAddChunk',
'~*Readable.push',
'~*readableAddChunk',
' Builtin:ArgumentsAdaptorTrampoline',
'~emit',
'~socketOnData',
'~*emit',
'~*socketOnData',
' Stub:CEntryStub',

@@ -148,11 +182,11 @@ 'v8::internal::Builtin_HandleApiCall(int, v8::internal::Object**, v8::internal::Isolate*)',

' Builtin:JSEntryTrampoline',
'~parserOnHeadersComplete',
'~parserOnIncoming',
'~*parserOnHeadersComplete',
'~*parserOnIncoming',
' Builtin:ArgumentsAdaptorTrampoline',
'~emit',
'~onRequest',
'~cal_arrayConcat',
'~reduce',
'~*emit',
'~*onRequest',
'~*cal_arrayConcat',
'~*reduce',
' Builtin:ArgumentsAdaptorTrampoline',
'*toFib',
'~*toFib',
' Stub:CEntryStub',

@@ -164,6 +198,8 @@ 'v8::internal::Builtin_ArrayConcat(int, v8::internal::Object**, v8::internal::Isolate*)',

' Builtin:JSEntryTrampoline',
'*ArrayConcatJS',
'~*ArrayConcatJS',
' Stub:CEntryStub',
'v8::internal::Runtime_ArrayConcat(int, v8::internal::Object**, v8::internal::Isolate*)' ] }
check(t, stack1, { v8internals: true }, opts)

@@ -170,0 +206,0 @@ })

@@ -44,5 +44,5 @@ 'use strict';

'v8::Context::New(v8::Isolate*, v8::ExtensionConfiguration*, v8::Handle<v8::ObjectTemplate>, v8::Handle<v8::Value>)',
'Script:~native messages.js',
'~SetUpError native ',
'~SetUpError.a native ',
'~*native messages.js',
'~*SetUpError native ',
'~*SetUpError.a native ',
'strlen' ] }

@@ -72,5 +72,5 @@

'Builtin:JSEntryTrampoline',
'Script:~native messages.js',
'~SetUpError native ',
'~SetUpError.a native ',
'~*native messages.js',
'~*SetUpError native ',
'~*SetUpError.a native ',
'Stub:CEntryStub',

@@ -100,5 +100,5 @@ 'v8::internal::LoadIC_Miss(int, v8::internal::Object**, v8::internal::Isolate*)',

'v8::Context::New(v8::Isolate*, v8::ExtensionConfiguration*, v8::Handle<v8::ObjectTemplate>, v8::Handle<v8::Value>)',
'Script:~native messages.js',
'~SetUpError native ',
'~SetUpError.a native ',
'~*native messages.js',
'~*SetUpError native ',
'~*SetUpError.a native ',
'strlen' ] }

@@ -105,0 +105,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc