mirror of https://github.com/nodejs/node.git
benchmark: add dotenv benchmark
PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
parent
e49cf7acfb
commit
53cba82e55
|
@ -0,0 +1,67 @@
|
|||
BASIC=basic
|
||||
|
||||
# COMMENTS=work
|
||||
#BASIC=basic2
|
||||
#BASIC=basic3
|
||||
|
||||
# previous line intentionally left blank
|
||||
AFTER_LINE=after_line
|
||||
EMPTY=
|
||||
EMPTY_SINGLE_QUOTES=''
|
||||
EMPTY_DOUBLE_QUOTES=""
|
||||
EMPTY_BACKTICKS=``
|
||||
SINGLE_QUOTES='single_quotes'
|
||||
SINGLE_QUOTES_SPACED=' single quotes '
|
||||
DOUBLE_QUOTES="double_quotes"
|
||||
DOUBLE_QUOTES_SPACED=" double quotes "
|
||||
DOUBLE_QUOTES_INSIDE_SINGLE='double "quotes" work inside single quotes'
|
||||
DOUBLE_QUOTES_WITH_NO_SPACE_BRACKET="{ port: $MONGOLAB_PORT}"
|
||||
SINGLE_QUOTES_INSIDE_DOUBLE="single 'quotes' work inside double quotes"
|
||||
BACKTICKS_INSIDE_SINGLE='`backticks` work inside single quotes'
|
||||
BACKTICKS_INSIDE_DOUBLE="`backticks` work inside double quotes"
|
||||
BACKTICKS=`backticks`
|
||||
BACKTICKS_SPACED=` backticks `
|
||||
DOUBLE_QUOTES_INSIDE_BACKTICKS=`double "quotes" work inside backticks`
|
||||
SINGLE_QUOTES_INSIDE_BACKTICKS=`single 'quotes' work inside backticks`
|
||||
DOUBLE_AND_SINGLE_QUOTES_INSIDE_BACKTICKS=`double "quotes" and single 'quotes' work inside backticks`
|
||||
EXPAND_NEWLINES="expand\nnew\nlines"
|
||||
DONT_EXPAND_UNQUOTED=dontexpand\nnewlines
|
||||
DONT_EXPAND_SQUOTED='dontexpand\nnewlines'
|
||||
# COMMENTS=work
|
||||
INLINE_COMMENTS=inline comments # work #very #well
|
||||
INLINE_COMMENTS_SINGLE_QUOTES='inline comments outside of #singlequotes' # work
|
||||
INLINE_COMMENTS_DOUBLE_QUOTES="inline comments outside of #doublequotes" # work
|
||||
INLINE_COMMENTS_BACKTICKS=`inline comments outside of #backticks` # work
|
||||
INLINE_COMMENTS_SPACE=inline comments start with a#number sign. no space required.
|
||||
EQUAL_SIGNS=equals==
|
||||
RETAIN_INNER_QUOTES={"foo": "bar"}
|
||||
RETAIN_INNER_QUOTES_AS_STRING='{"foo": "bar"}'
|
||||
RETAIN_INNER_QUOTES_AS_BACKTICKS=`{"foo": "bar's"}`
|
||||
TRIM_SPACE_FROM_UNQUOTED= some spaced out string
|
||||
SPACE_BEFORE_DOUBLE_QUOTES= "space before double quotes"
|
||||
EMAIL=therealnerdybeast@example.tld
|
||||
SPACED_KEY = parsed
|
||||
EDGE_CASE_INLINE_COMMENTS="VALUE1" # or "VALUE2" or "VALUE3"
|
||||
|
||||
MULTI_DOUBLE_QUOTED="THIS
|
||||
IS
|
||||
A
|
||||
MULTILINE
|
||||
STRING"
|
||||
|
||||
MULTI_SINGLE_QUOTED='THIS
|
||||
IS
|
||||
A
|
||||
MULTILINE
|
||||
STRING'
|
||||
|
||||
MULTI_BACKTICKED=`THIS
|
||||
IS
|
||||
A
|
||||
"MULTILINE'S"
|
||||
STRING`
|
||||
export EXPORT_EXAMPLE = ignore export
|
||||
|
||||
MULTI_NOT_VALID_QUOTE="
|
||||
MULTI_NOT_VALID=THIS
|
||||
IS NOT MULTILINE
|
|
@ -0,0 +1,23 @@
|
|||
'use strict';
|
||||
|
||||
const { createBenchmark } = require('../common.js');
|
||||
const path = require('node:path');
|
||||
const fs = require('node:fs');
|
||||
const util = require('node:util');
|
||||
const assert = require('node:assert');
|
||||
|
||||
const bench = createBenchmark(main, {
|
||||
n: 3e4,
|
||||
});
|
||||
|
||||
const env = fs.readFileSync(path.resolve(__dirname, '../fixtures/valid.env'), 'utf-8');
|
||||
|
||||
function main({ n }) {
|
||||
let noDead;
|
||||
bench.start();
|
||||
for (let i = 0; i < n; i++) {
|
||||
noDead = util.parseEnv(env);
|
||||
}
|
||||
bench.end(n);
|
||||
assert(noDead !== undefined);
|
||||
}
|
Loading…
Reference in New Issue