Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 23b628d

Browse filesBrowse files
avivkellertargos
authored andcommitted
benchmark: add dotenv benchmark
PR-URL: #54278 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
1 parent c89c934 commit 23b628d
Copy full SHA for 23b628d

File tree

Expand file treeCollapse file tree

2 files changed

+90
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+90
-0
lines changed
Open diff view settings
Collapse file

‎benchmark/fixtures/valid.env‎

Copy file name to clipboard
+67Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
BASIC=basic
2+
3+
# COMMENTS=work
4+
#BASIC=basic2
5+
#BASIC=basic3
6+
7+
# previous line intentionally left blank
8+
AFTER_LINE=after_line
9+
EMPTY=
10+
EMPTY_SINGLE_QUOTES=''
11+
EMPTY_DOUBLE_QUOTES=""
12+
EMPTY_BACKTICKS=``
13+
SINGLE_QUOTES='single_quotes'
14+
SINGLE_QUOTES_SPACED=' single quotes '
15+
DOUBLE_QUOTES="double_quotes"
16+
DOUBLE_QUOTES_SPACED=" double quotes "
17+
DOUBLE_QUOTES_INSIDE_SINGLE='double "quotes" work inside single quotes'
18+
DOUBLE_QUOTES_WITH_NO_SPACE_BRACKET="{ port: $MONGOLAB_PORT}"
19+
SINGLE_QUOTES_INSIDE_DOUBLE="single 'quotes' work inside double quotes"
20+
BACKTICKS_INSIDE_SINGLE='`backticks` work inside single quotes'
21+
BACKTICKS_INSIDE_DOUBLE="`backticks` work inside double quotes"
22+
BACKTICKS=`backticks`
23+
BACKTICKS_SPACED=` backticks `
24+
DOUBLE_QUOTES_INSIDE_BACKTICKS=`double "quotes" work inside backticks`
25+
SINGLE_QUOTES_INSIDE_BACKTICKS=`single 'quotes' work inside backticks`
26+
DOUBLE_AND_SINGLE_QUOTES_INSIDE_BACKTICKS=`double "quotes" and single 'quotes' work inside backticks`
27+
EXPAND_NEWLINES="expand\nnew\nlines"
28+
DONT_EXPAND_UNQUOTED=dontexpand\nnewlines
29+
DONT_EXPAND_SQUOTED='dontexpand\nnewlines'
30+
# COMMENTS=work
31+
INLINE_COMMENTS=inline comments # work #very #well
32+
INLINE_COMMENTS_SINGLE_QUOTES='inline comments outside of #singlequotes' # work
33+
INLINE_COMMENTS_DOUBLE_QUOTES="inline comments outside of #doublequotes" # work
34+
INLINE_COMMENTS_BACKTICKS=`inline comments outside of #backticks` # work
35+
INLINE_COMMENTS_SPACE=inline comments start with a#number sign. no space required.
36+
EQUAL_SIGNS=equals==
37+
RETAIN_INNER_QUOTES={"foo": "bar"}
38+
RETAIN_INNER_QUOTES_AS_STRING='{"foo": "bar"}'
39+
RETAIN_INNER_QUOTES_AS_BACKTICKS=`{"foo": "bar's"}`
40+
TRIM_SPACE_FROM_UNQUOTED= some spaced out string
41+
SPACE_BEFORE_DOUBLE_QUOTES= "space before double quotes"
42+
EMAIL=therealnerdybeast@example.tld
43+
SPACED_KEY = parsed
44+
EDGE_CASE_INLINE_COMMENTS="VALUE1" # or "VALUE2" or "VALUE3"
45+
46+
MULTI_DOUBLE_QUOTED="THIS
47+
IS
48+
A
49+
MULTILINE
50+
STRING"
51+
52+
MULTI_SINGLE_QUOTED='THIS
53+
IS
54+
A
55+
MULTILINE
56+
STRING'
57+
58+
MULTI_BACKTICKED=`THIS
59+
IS
60+
A
61+
"MULTILINE'S"
62+
STRING`
63+
export EXPORT_EXAMPLE = ignore export
64+
65+
MULTI_NOT_VALID_QUOTE="
66+
MULTI_NOT_VALID=THIS
67+
IS NOT MULTILINE
Collapse file

‎benchmark/util/parse-env.js‎

Copy file name to clipboard
+23Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
'use strict';
2+
3+
const { createBenchmark } = require('../common.js');
4+
const path = require('node:path');
5+
const fs = require('node:fs');
6+
const util = require('node:util');
7+
const assert = require('node:assert');
8+
9+
const bench = createBenchmark(main, {
10+
n: 3e4,
11+
});
12+
13+
const env = fs.readFileSync(path.resolve(__dirname, '../fixtures/valid.env'), 'utf-8');
14+
15+
function main({ n }) {
16+
let noDead;
17+
bench.start();
18+
for (let i = 0; i < n; i++) {
19+
noDead = util.parseEnv(env);
20+
}
21+
bench.end(n);
22+
assert(noDead !== undefined);
23+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.