Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .gitlab/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ benchmark:
GROUP: 3
- MAJOR_VERSION: 18
GROUP: 4
- MAJOR_VERSION: 18
GROUP: 5
- MAJOR_VERSION: 20
GROUP: 1
- MAJOR_VERSION: 20
Expand All @@ -65,6 +67,8 @@ benchmark:
GROUP: 3
- MAJOR_VERSION: 20
GROUP: 4
- MAJOR_VERSION: 20
GROUP: 5
- MAJOR_VERSION: 22
GROUP: 1
- MAJOR_VERSION: 22
Expand All @@ -73,6 +77,8 @@ benchmark:
GROUP: 3
- MAJOR_VERSION: 22
GROUP: 4
- MAJOR_VERSION: 22
GROUP: 5
- MAJOR_VERSION: 24
GROUP: 1
- MAJOR_VERSION: 24
Expand All @@ -81,8 +87,10 @@ benchmark:
GROUP: 3
- MAJOR_VERSION: 24
GROUP: 4
- MAJOR_VERSION: 24
GROUP: 5
variables:
SPLITS: 4
SPLITS: 5

benchmark-serverless:
stage: benchmarks
Expand Down
1 change: 1 addition & 0 deletions benchmark/sirun/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ WORKDIR /opt/insecure-bank-js
RUN git checkout 2003d9085a6e9a679e31fd88719e4de030d6855f
RUN . $NVM_DIR/nvm.sh \
&& npm ci \
&& npm install --silent acorn oxc-parser @swc/core \
&& npm cache clean --force

WORKDIR /app
49 changes: 49 additions & 0 deletions benchmark/sirun/ast-parser/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
'use strict'

/* eslint-disable import/no-extraneous-dependencies */
/* eslint-disable n/no-extraneous-require */

const {
PARSE,
USE_ACORN,
USE_OXC,
USE_SWC
} = process.env

const code = `
const { useState } = require('react');

function MyComponent() {
const [count, setCount] = useState(0);

const increment = () => {
setCount(count + 1);
};

return 'test';
}
`

if (USE_ACORN === 'true') {
const { parse } = require('acorn')

if (PARSE === 'true') {
parse(code, { ecmaVersion: 2020 })
}
}

if (USE_OXC === 'true') {
const { parseSync } = require('oxc-parser')

if (PARSE === 'true') {
parseSync('index.js', code)
}
}

if (USE_SWC === 'true') {
const { parseSync } = require('@swc/core')

if (PARSE === 'true') {
parseSync(code)
}
}
35 changes: 35 additions & 0 deletions benchmark/sirun/ast-parser/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "ast-parser",
"run": "node .",
"run_with_affinity": "bash -c \"taskset -c $CPU_AFFINITY node .\"",
"cachegrind": false,
"instructions": true,
"iterations": 20,
"variants": {
"control": {},
"acorn-load": {
"baseline": "control",
"env": { "USE_ACORN": "true" }
},
"acorn-load-parse": {
"baseline": "control",
"env": { "USE_ACORN": "true", "PARSE": "true" }
},
"oxc-load": {
"baseline": "control",
"env": { "USE_OXC": "true" }
},
"oxc-load-parse": {
"baseline": "control",
"env": { "USE_OXC": "true", "PARSE": "true" }
},
"swc-load": {
"baseline": "control",
"env": { "USE_SWC": "true" }
},
"swc-load-parse": {
"baseline": "control",
"env": { "USE_SWC": "true", "PARSE": "true" }
}
}
}
1 change: 1 addition & 0 deletions benchmark/sirun/runall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ fi
cd ../../ &&
npm install --global yarn || (sleep 60 && npm install --global yarn) \
&& yarn install --ignore-engines || (sleep 60 && yarn install --ignore-engines) \
&& yarn add --silent acorn oxc-parser @swc/core \
&& PLUGINS="bluebird|q|graphql|express" yarn services
)

Expand Down
49 changes: 49 additions & 0 deletions orchestrion.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
'use strict'

const codeTransformer = require('@apm-js-collab/code-transformer')

Check failure on line 3 in orchestrion.js

View workflow job for this annotation

GitHub Actions / lint

Can't resolve '@apm-js-collab/code-transformer' in '/home/runner/work/dd-trace-js/dd-trace-js'

// The full instrumentation config
const instrumentation = {
// The name of the diagnostics channel
channelName: 'my-channel',
// Define the module you'd like to inject tracing channels into
module: {
name: 'my-module',
versionRange: '>=1.0.0',
filePath: './dist/index.js',
},
// Define the function you'd like to instrument
// (e.g., match a method named 'foo' that returns a Promise)
functionQuery: {
methodName: 'fetch',
kind: 'Async',
},
}

// Create an InstrumentationMatcher with an array of instrumentation configs
const matcher = codeTransformer.create([instrumentation])

// Get a transformer for a specific module
const transformer = matcher.getTransformer(
'my-module',
'1.2.3',
'./dist/index.js',
)

if (transformer === undefined) {
throw new Error('No transformer found for module')
}

// Transform code
const inputCode = 'async function fetch() { return 42; }'

try {
const result = transformer.transform(inputCode, 'unknown')
console.log(result.code)

Check failure on line 42 in orchestrion.js

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement
} catch (e) {
console.log(e)

Check failure on line 44 in orchestrion.js

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement
}

// Both the matcher and transformer should be freed after use!
matcher.free()
transformer.free()
34 changes: 6 additions & 28 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4566,16 +4566,8 @@ streamsearch@^1.1.0:
resolved "https://registry.yarnpkg.com/streamsearch/-/streamsearch-1.1.0.tgz#404dd1e2247ca94af554e841a8ef0eaa238da764"
integrity sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==

"string-width-cjs@npm:string-width@^4.2.0":
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"

string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3:
"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3:
name string-width-cjs
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
Expand Down Expand Up @@ -4639,14 +4631,8 @@ string_decoder@~1.1.1:
dependencies:
safe-buffer "~5.1.0"

"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
dependencies:
ansi-regex "^5.0.1"

strip-ansi@^6.0.0, strip-ansi@^6.0.1:
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
name strip-ansi-cjs
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
Expand Down Expand Up @@ -5127,7 +5113,8 @@ workerpool@^9.2.0:
resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-9.3.4.tgz#f6c92395b2141afd78e2a889e80cb338fe9fca41"
integrity sha512-TmPRQYYSAnnDiEB0P/Ytip7bFGvqnSU6I2BcuSw7Hx+JSg/DsUi5ebYfc8GYaSdpuvOcEs6dXxPurOYpe9QFwg==

"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
name wrap-ansi-cjs
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
Expand All @@ -5145,15 +5132,6 @@ wrap-ansi@^6.2.0:
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
dependencies:
ansi-styles "^4.0.0"
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^8.1.0:
version "8.1.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"
Expand Down
Loading