tedious 19.0.0 → 19.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/all-headers.js +1 -1
- package/lib/all-headers.js.map +1 -1
- package/lib/always-encrypted/aead-aes-256-cbc-hmac-algorithm.js +1 -1
- package/lib/always-encrypted/aead-aes-256-cbc-hmac-algorithm.js.map +1 -1
- package/lib/always-encrypted/aead-aes-256-cbc-hmac-encryption-key.js +2 -2
- package/lib/always-encrypted/aead-aes-256-cbc-hmac-encryption-key.js.map +1 -1
- package/lib/always-encrypted/cek-entry.js +1 -1
- package/lib/always-encrypted/cek-entry.js.map +1 -1
- package/lib/always-encrypted/get-parameter-encryption-metadata.js +2 -2
- package/lib/always-encrypted/get-parameter-encryption-metadata.js.map +1 -1
- package/lib/always-encrypted/key-crypto.js +1 -1
- package/lib/always-encrypted/key-crypto.js.map +1 -1
- package/lib/always-encrypted/keystore-provider-azure-key-vault.js +1 -1
- package/lib/always-encrypted/keystore-provider-azure-key-vault.js.map +1 -1
- package/lib/always-encrypted/symmetric-key-cache.js +2 -2
- package/lib/always-encrypted/symmetric-key-cache.js.map +1 -1
- package/lib/always-encrypted/symmetric-key.js +1 -1
- package/lib/always-encrypted/symmetric-key.js.map +1 -1
- package/lib/always-encrypted/types.js +1 -1
- package/lib/always-encrypted/types.js.map +1 -1
- package/lib/always-encrypted/utils.js +1 -1
- package/lib/always-encrypted/utils.js.map +1 -1
- package/lib/bulk-load-payload.js +1 -1
- package/lib/bulk-load-payload.js.map +1 -1
- package/lib/bulk-load.js +2 -2
- package/lib/bulk-load.js.map +1 -1
- package/lib/collation.js +1 -1
- package/lib/collation.js.map +1 -1
- package/lib/connection.d.ts +44 -50
- package/lib/connection.js +579 -580
- package/lib/connection.js.map +1 -1
- package/lib/connector.js +2 -2
- package/lib/connector.js.map +1 -1
- package/lib/data-type.js +2 -2
- package/lib/data-type.js.map +1 -1
- package/lib/data-types/bigint.js +2 -2
- package/lib/data-types/bigint.js.map +1 -1
- package/lib/data-types/binary.js +1 -1
- package/lib/data-types/binary.js.map +1 -1
- package/lib/data-types/bit.js +2 -2
- package/lib/data-types/bit.js.map +1 -1
- package/lib/data-types/bitn.js +1 -1
- package/lib/data-types/bitn.js.map +1 -1
- package/lib/data-types/char.js +2 -2
- package/lib/data-types/char.js.map +1 -1
- package/lib/data-types/date.js +1 -1
- package/lib/data-types/date.js.map +1 -1
- package/lib/data-types/datetime.js +2 -2
- package/lib/data-types/datetime.js.map +1 -1
- package/lib/data-types/datetime2.js +2 -2
- package/lib/data-types/datetime2.js.map +1 -1
- package/lib/data-types/datetimen.js +1 -1
- package/lib/data-types/datetimen.js.map +1 -1
- package/lib/data-types/datetimeoffset.js +2 -2
- package/lib/data-types/datetimeoffset.js.map +1 -1
- package/lib/data-types/decimal.js +2 -2
- package/lib/data-types/decimal.js.map +1 -1
- package/lib/data-types/decimaln.js +1 -1
- package/lib/data-types/decimaln.js.map +1 -1
- package/lib/data-types/float.js +2 -2
- package/lib/data-types/float.js.map +1 -1
- package/lib/data-types/floatn.js +1 -1
- package/lib/data-types/floatn.js.map +1 -1
- package/lib/data-types/image.js +1 -1
- package/lib/data-types/image.js.map +1 -1
- package/lib/data-types/int.js +2 -2
- package/lib/data-types/int.js.map +1 -1
- package/lib/data-types/intn.js +1 -1
- package/lib/data-types/intn.js.map +1 -1
- package/lib/data-types/money.js +2 -2
- package/lib/data-types/money.js.map +1 -1
- package/lib/data-types/moneyn.js +1 -1
- package/lib/data-types/moneyn.js.map +1 -1
- package/lib/data-types/nchar.js +1 -1
- package/lib/data-types/nchar.js.map +1 -1
- package/lib/data-types/ntext.js +1 -1
- package/lib/data-types/ntext.js.map +1 -1
- package/lib/data-types/null.js +1 -1
- package/lib/data-types/null.js.map +1 -1
- package/lib/data-types/numeric.js +2 -2
- package/lib/data-types/numeric.js.map +1 -1
- package/lib/data-types/numericn.js +1 -1
- package/lib/data-types/numericn.js.map +1 -1
- package/lib/data-types/nvarchar.js +1 -1
- package/lib/data-types/nvarchar.js.map +1 -1
- package/lib/data-types/real.js +2 -2
- package/lib/data-types/real.js.map +1 -1
- package/lib/data-types/smalldatetime.js +2 -2
- package/lib/data-types/smalldatetime.js.map +1 -1
- package/lib/data-types/smallint.js +2 -2
- package/lib/data-types/smallint.js.map +1 -1
- package/lib/data-types/smallmoney.js +2 -2
- package/lib/data-types/smallmoney.js.map +1 -1
- package/lib/data-types/sql-variant.js +1 -1
- package/lib/data-types/sql-variant.js.map +1 -1
- package/lib/data-types/text.js +2 -2
- package/lib/data-types/text.js.map +1 -1
- package/lib/data-types/time.js +2 -2
- package/lib/data-types/time.js.map +1 -1
- package/lib/data-types/tinyint.js +2 -2
- package/lib/data-types/tinyint.js.map +1 -1
- package/lib/data-types/tvp.js +2 -2
- package/lib/data-types/tvp.js.map +1 -1
- package/lib/data-types/udt.js +1 -1
- package/lib/data-types/udt.js.map +1 -1
- package/lib/data-types/uniqueidentifier.js +1 -1
- package/lib/data-types/uniqueidentifier.js.map +1 -1
- package/lib/data-types/varbinary.js +1 -1
- package/lib/data-types/varbinary.js.map +1 -1
- package/lib/data-types/varchar.js +2 -2
- package/lib/data-types/varchar.js.map +1 -1
- package/lib/data-types/xml.js +1 -1
- package/lib/data-types/xml.js.map +1 -1
- package/lib/debug.js +2 -2
- package/lib/debug.js.map +1 -1
- package/lib/errors.js +1 -1
- package/lib/errors.js.map +1 -1
- package/lib/guid-parser.js +1 -1
- package/lib/guid-parser.js.map +1 -1
- package/lib/incoming-message-stream.js +2 -2
- package/lib/incoming-message-stream.js.map +1 -1
- package/lib/instance-lookup.js +2 -2
- package/lib/instance-lookup.js.map +1 -1
- package/lib/library.js +1 -1
- package/lib/library.js.map +1 -1
- package/lib/login7-payload.js +1 -1
- package/lib/login7-payload.js.map +1 -1
- package/lib/message-io.js +3 -3
- package/lib/message-io.js.map +1 -1
- package/lib/message.js +1 -1
- package/lib/message.js.map +1 -1
- package/lib/metadata-parser.js +1 -1
- package/lib/metadata-parser.js.map +1 -1
- package/lib/ntlm-payload.js +3 -3
- package/lib/ntlm-payload.js.map +1 -1
- package/lib/ntlm.js +1 -1
- package/lib/ntlm.js.map +1 -1
- package/lib/outgoing-message-stream.js +2 -2
- package/lib/outgoing-message-stream.js.map +1 -1
- package/lib/packet.js +1 -1
- package/lib/packet.js.map +1 -1
- package/lib/prelogin-payload.js +2 -2
- package/lib/prelogin-payload.js.map +1 -1
- package/lib/request.js +1 -1
- package/lib/request.js.map +1 -1
- package/lib/rpcrequest-payload.js +2 -2
- package/lib/rpcrequest-payload.js.map +1 -1
- package/lib/sender.js +2 -2
- package/lib/sender.js.map +1 -1
- package/lib/special-stored-procedure.js +1 -1
- package/lib/special-stored-procedure.js.map +1 -1
- package/lib/sqlbatch-payload.js +2 -2
- package/lib/sqlbatch-payload.js.map +1 -1
- package/lib/tds-versions.js +1 -1
- package/lib/tds-versions.js.map +1 -1
- package/lib/tedious.js +2 -2
- package/lib/tedious.js.map +1 -1
- package/lib/token/colmetadata-token-parser.js +1 -1
- package/lib/token/colmetadata-token-parser.js.map +1 -1
- package/lib/token/done-token-parser.js +1 -1
- package/lib/token/done-token-parser.js.map +1 -1
- package/lib/token/env-change-token-parser.js +1 -1
- package/lib/token/env-change-token-parser.js.map +1 -1
- package/lib/token/feature-ext-ack-parser.js +1 -1
- package/lib/token/feature-ext-ack-parser.js.map +1 -1
- package/lib/token/fedauth-info-parser.js +1 -1
- package/lib/token/fedauth-info-parser.js.map +1 -1
- package/lib/token/handler.js +2 -2
- package/lib/token/handler.js.map +1 -1
- package/lib/token/helpers.js +1 -1
- package/lib/token/helpers.js.map +1 -1
- package/lib/token/infoerror-token-parser.js +1 -1
- package/lib/token/infoerror-token-parser.js.map +1 -1
- package/lib/token/loginack-token-parser.js +1 -1
- package/lib/token/loginack-token-parser.js.map +1 -1
- package/lib/token/nbcrow-token-parser.js +2 -2
- package/lib/token/nbcrow-token-parser.js.map +1 -1
- package/lib/token/order-token-parser.js +1 -1
- package/lib/token/order-token-parser.js.map +1 -1
- package/lib/token/returnstatus-token-parser.js +1 -1
- package/lib/token/returnstatus-token-parser.js.map +1 -1
- package/lib/token/returnvalue-token-parser.js +2 -2
- package/lib/token/returnvalue-token-parser.js.map +1 -1
- package/lib/token/row-token-parser.js +2 -2
- package/lib/token/row-token-parser.js.map +1 -1
- package/lib/token/sspi-token-parser.js +1 -1
- package/lib/token/sspi-token-parser.js.map +1 -1
- package/lib/token/stream-parser.js +2 -2
- package/lib/token/stream-parser.js.map +1 -1
- package/lib/token/token-stream-parser.js +2 -2
- package/lib/token/token-stream-parser.js.map +1 -1
- package/lib/token/token.js +1 -1
- package/lib/token/token.js.map +1 -1
- package/lib/tracking-buffer/writable-tracking-buffer.js +1 -1
- package/lib/tracking-buffer/writable-tracking-buffer.js.map +1 -1
- package/lib/transaction.js +2 -2
- package/lib/transaction.js.map +1 -1
- package/lib/transient-error-lookup.js +1 -1
- package/lib/transient-error-lookup.js.map +1 -1
- package/lib/value-parser.js +2 -2
- package/lib/value-parser.js.map +1 -1
- package/package.json +18 -19
- package/benchmarks/README.md +0 -12
- package/benchmarks/bulk-load/iterable.js +0 -61
- package/benchmarks/common.js +0 -287
- package/benchmarks/connection/open.js +0 -26
- package/benchmarks/package-lock.json +0 -21173
- package/benchmarks/package.json +0 -11
- package/benchmarks/query/call-tvp.js +0 -105
- package/benchmarks/query/insert-varbinary.js +0 -46
- package/benchmarks/query/select-many-rows.js +0 -63
- package/benchmarks/query/select-nvarchar.js +0 -50
- package/benchmarks/query/select-varbinary.js +0 -50
- package/benchmarks/request/rpcrequest-payload-tvp.js +0 -45
- package/benchmarks/request/rpcrequest-payload-varbinary.js +0 -37
- package/benchmarks/token-parser/colmetadata-token.js +0 -27
- package/benchmarks/token-parser/done-token.js +0 -28
- package/benchmarks/token-parser/simple-tokens.js +0 -363
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
const { createBenchmark, createConnection } = require('../common');
|
|
4
|
-
|
|
5
|
-
const { Request, TYPES } = require('tedious');
|
|
6
|
-
|
|
7
|
-
const bench = createBenchmark(main, {
|
|
8
|
-
n: [10, 100],
|
|
9
|
-
size: [
|
|
10
|
-
10,
|
|
11
|
-
100,
|
|
12
|
-
1000,
|
|
13
|
-
10000
|
|
14
|
-
]
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
function main({ n, size }) {
|
|
18
|
-
createConnection((connection) => {
|
|
19
|
-
const request = new Request(`
|
|
20
|
-
CREATE TABLE "#tmpTestTable" (
|
|
21
|
-
"id" int NOT NULL
|
|
22
|
-
)
|
|
23
|
-
`, (err) => {
|
|
24
|
-
if (err) {
|
|
25
|
-
throw err;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
let i = 0;
|
|
29
|
-
|
|
30
|
-
bench.start();
|
|
31
|
-
|
|
32
|
-
(function cb() {
|
|
33
|
-
const bulkLoad = connection.newBulkLoad('#tmpTestTable', (err) => {
|
|
34
|
-
if (err) {
|
|
35
|
-
throw err;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (i++ === n) {
|
|
39
|
-
bench.end(n);
|
|
40
|
-
|
|
41
|
-
connection.close();
|
|
42
|
-
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
cb();
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
bulkLoad.addColumn('id', TYPES.Int, { nullable: false });
|
|
50
|
-
|
|
51
|
-
const rows = [];
|
|
52
|
-
for (let j = 0; j < size; j++) {
|
|
53
|
-
rows.push([ j ]);
|
|
54
|
-
}
|
|
55
|
-
connection.execBulkLoad(bulkLoad, rows);
|
|
56
|
-
})();
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
connection.execSqlBatch(request);
|
|
60
|
-
});
|
|
61
|
-
}
|
package/benchmarks/common.js
DELETED
|
@@ -1,287 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const fs = require('fs');
|
|
4
|
-
const child_process = require('child_process');
|
|
5
|
-
|
|
6
|
-
const {
|
|
7
|
-
PerformanceObserver,
|
|
8
|
-
constants: {
|
|
9
|
-
NODE_PERFORMANCE_GC_INCREMENTAL,
|
|
10
|
-
NODE_PERFORMANCE_GC_MAJOR,
|
|
11
|
-
NODE_PERFORMANCE_GC_MINOR
|
|
12
|
-
}
|
|
13
|
-
} = require('perf_hooks');
|
|
14
|
-
|
|
15
|
-
const { Connection } = require('tedious');
|
|
16
|
-
|
|
17
|
-
// The `Benchmark` class is taken from Node.js - see
|
|
18
|
-
// https://github.com/nodejs/node/blob/0f96dc266fd0cd8c1baa82ce7eb951c11b29a331/benchmark/common.js
|
|
19
|
-
// Copyright Node.js contributors. All rights reserved.
|
|
20
|
-
function Benchmark(fn, configs, options) {
|
|
21
|
-
// Use the file name as the name of the benchmark
|
|
22
|
-
this.name = require.main.filename.slice(__dirname.length + 1);
|
|
23
|
-
// Parse job-specific configuration from the command line arguments
|
|
24
|
-
const parsed_args = this._parseArgs(process.argv.slice(2), configs);
|
|
25
|
-
this.options = parsed_args.cli;
|
|
26
|
-
this.extra_options = parsed_args.extra;
|
|
27
|
-
// The configuration list as a queue of jobs
|
|
28
|
-
this.queue = this._queue(this.options);
|
|
29
|
-
// The configuration of the current job, head of the queue
|
|
30
|
-
this.config = this.queue[0];
|
|
31
|
-
// Execution arguments i.e. flags used to run the jobs
|
|
32
|
-
this.flags = [];
|
|
33
|
-
if (options && options.flags) {
|
|
34
|
-
this.flags = this.flags.concat(options.flags);
|
|
35
|
-
}
|
|
36
|
-
if (process.env.NODE_BENCHMARK_FLAGS) {
|
|
37
|
-
const flags = process.env.NODE_BENCHMARK_FLAGS.split(/\s+/);
|
|
38
|
-
this.flags = this.flags.concat(flags);
|
|
39
|
-
}
|
|
40
|
-
// Holds process.hrtime value
|
|
41
|
-
this._time = [0, 0];
|
|
42
|
-
// Used to make sure a benchmark only start a timer once
|
|
43
|
-
this._started = false;
|
|
44
|
-
|
|
45
|
-
this._gcStats = {
|
|
46
|
-
[NODE_PERFORMANCE_GC_INCREMENTAL]: {
|
|
47
|
-
count: 0,
|
|
48
|
-
totalDuration: 0
|
|
49
|
-
},
|
|
50
|
-
[NODE_PERFORMANCE_GC_MINOR]: {
|
|
51
|
-
count: 0,
|
|
52
|
-
totalDuration: 0
|
|
53
|
-
},
|
|
54
|
-
[NODE_PERFORMANCE_GC_MAJOR]: {
|
|
55
|
-
count: 0,
|
|
56
|
-
totalDuration: 0
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
this._observer = new PerformanceObserver((list) => {
|
|
61
|
-
const entries = list.getEntries();
|
|
62
|
-
const length = entries.length;
|
|
63
|
-
|
|
64
|
-
for (let i = 0; i < length; i++) {
|
|
65
|
-
const entry = entries[i];
|
|
66
|
-
const stats = this._gcStats[entry.detail.kind];
|
|
67
|
-
|
|
68
|
-
if (stats) {
|
|
69
|
-
stats.count += 1;
|
|
70
|
-
stats.totalDuration += entry.duration;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
// this._run will use fork() to create a new process for each configuration
|
|
76
|
-
// combination.
|
|
77
|
-
if (process.env.hasOwnProperty('NODE_RUN_BENCHMARK_FN')) {
|
|
78
|
-
process.nextTick(() => fn(this.config));
|
|
79
|
-
} else {
|
|
80
|
-
process.nextTick(() => this._run());
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
Benchmark.prototype._parseArgs = function(argv, configs) {
|
|
85
|
-
const cliOptions = {};
|
|
86
|
-
const extraOptions = {};
|
|
87
|
-
const validArgRE = /^(.+?)=([\s\S]*)$/;
|
|
88
|
-
// Parse configuration arguments
|
|
89
|
-
for (const arg of argv) {
|
|
90
|
-
const match = arg.match(validArgRE);
|
|
91
|
-
if (!match) {
|
|
92
|
-
console.error(`bad argument: ${arg}`);
|
|
93
|
-
process.exit(1);
|
|
94
|
-
}
|
|
95
|
-
const config = match[1];
|
|
96
|
-
|
|
97
|
-
if (configs[config]) {
|
|
98
|
-
// Infer the type from the config object and parse accordingly
|
|
99
|
-
const isNumber = typeof configs[config][0] === 'number';
|
|
100
|
-
const value = isNumber ? +match[2] : match[2];
|
|
101
|
-
if (!cliOptions[config])
|
|
102
|
-
cliOptions[config] = [];
|
|
103
|
-
cliOptions[config].push(value);
|
|
104
|
-
} else {
|
|
105
|
-
extraOptions[config] = match[2];
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
return { cli: Object.assign({}, configs, cliOptions), extra: extraOptions };
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
Benchmark.prototype._queue = function(options) {
|
|
112
|
-
const queue = [];
|
|
113
|
-
const keys = Object.keys(options);
|
|
114
|
-
|
|
115
|
-
// Perform a depth-first walk though all options to generate a
|
|
116
|
-
// configuration list that contains all combinations.
|
|
117
|
-
function recursive(keyIndex, prevConfig) {
|
|
118
|
-
const key = keys[keyIndex];
|
|
119
|
-
const values = options[key];
|
|
120
|
-
const type = typeof values[0];
|
|
121
|
-
|
|
122
|
-
for (const value of values) {
|
|
123
|
-
if (typeof value !== 'number' && typeof value !== 'string') {
|
|
124
|
-
throw new TypeError(`configuration "${key}" had type ${typeof value}`);
|
|
125
|
-
}
|
|
126
|
-
if (typeof value !== type) {
|
|
127
|
-
// This is a requirement for being able to consistently and predictably
|
|
128
|
-
// parse CLI provided configuration values.
|
|
129
|
-
throw new TypeError(`configuration "${key}" has mixed types`);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
const currConfig = Object.assign({ [key]: value }, prevConfig);
|
|
133
|
-
|
|
134
|
-
if (keyIndex + 1 < keys.length) {
|
|
135
|
-
recursive(keyIndex + 1, currConfig);
|
|
136
|
-
} else {
|
|
137
|
-
queue.push(currConfig);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
if (keys.length > 0) {
|
|
143
|
-
recursive(0, {});
|
|
144
|
-
} else {
|
|
145
|
-
queue.push({});
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
return queue;
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
Benchmark.prototype._run = function() {
|
|
152
|
-
const self = this;
|
|
153
|
-
// If forked, report to the parent.
|
|
154
|
-
if (process.send) {
|
|
155
|
-
process.send({
|
|
156
|
-
type: 'config',
|
|
157
|
-
name: this.name,
|
|
158
|
-
queueLength: this.queue.length,
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
(function recursive(queueIndex) {
|
|
163
|
-
const config = self.queue[queueIndex];
|
|
164
|
-
|
|
165
|
-
// Set NODE_RUN_BENCHMARK_FN to indicate that the child shouldn't construct
|
|
166
|
-
// a configuration queue, but just execute the benchmark function.
|
|
167
|
-
const childEnv = Object.assign({}, process.env);
|
|
168
|
-
childEnv.NODE_RUN_BENCHMARK_FN = '';
|
|
169
|
-
|
|
170
|
-
// Create configuration arguments
|
|
171
|
-
const childArgs = [];
|
|
172
|
-
for (const key of Object.keys(config)) {
|
|
173
|
-
childArgs.push(`${key}=${config[key]}`);
|
|
174
|
-
}
|
|
175
|
-
for (const key of Object.keys(self.extra_options)) {
|
|
176
|
-
childArgs.push(`${key}=${self.extra_options[key]}`);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
const child = child_process.fork(require.main.filename, childArgs, {
|
|
180
|
-
env: childEnv,
|
|
181
|
-
execArgv: self.flags.concat(process.execArgv),
|
|
182
|
-
});
|
|
183
|
-
child.on('message', sendResult);
|
|
184
|
-
child.on('close', (code) => {
|
|
185
|
-
if (code) {
|
|
186
|
-
process.exit(code);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
if (queueIndex + 1 < self.queue.length) {
|
|
190
|
-
recursive(queueIndex + 1);
|
|
191
|
-
}
|
|
192
|
-
});
|
|
193
|
-
})(0);
|
|
194
|
-
};
|
|
195
|
-
|
|
196
|
-
Benchmark.prototype.start = function() {
|
|
197
|
-
if (this._started) {
|
|
198
|
-
throw new Error('Called start more than once in a single benchmark');
|
|
199
|
-
}
|
|
200
|
-
this._started = true;
|
|
201
|
-
this._observer.observe({ entryTypes: ['gc'], buffered: false });
|
|
202
|
-
|
|
203
|
-
this._time = process.hrtime();
|
|
204
|
-
};
|
|
205
|
-
|
|
206
|
-
Benchmark.prototype.end = function(operations) {
|
|
207
|
-
// Get elapsed time now and do error checking later for accuracy.
|
|
208
|
-
const elapsed = process.hrtime(this._time);
|
|
209
|
-
|
|
210
|
-
if (!this._started) {
|
|
211
|
-
throw new Error('called end without start');
|
|
212
|
-
}
|
|
213
|
-
if (typeof operations !== 'number') {
|
|
214
|
-
throw new Error('called end() without specifying operation count');
|
|
215
|
-
}
|
|
216
|
-
if (!process.env.NODEJS_BENCHMARK_ZERO_ALLOWED && operations <= 0) {
|
|
217
|
-
throw new Error('called end() with operation count <= 0');
|
|
218
|
-
}
|
|
219
|
-
if (elapsed[0] === 0 && elapsed[1] === 0) {
|
|
220
|
-
if (!process.env.NODEJS_BENCHMARK_ZERO_ALLOWED)
|
|
221
|
-
throw new Error('insufficient clock precision for short benchmark');
|
|
222
|
-
// Avoid dividing by zero
|
|
223
|
-
elapsed[1] = 1;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
this._observer.disconnect();
|
|
227
|
-
|
|
228
|
-
const time = elapsed[0] + elapsed[1] / 1e9;
|
|
229
|
-
const rate = operations / time;
|
|
230
|
-
this.report(rate, elapsed);
|
|
231
|
-
};
|
|
232
|
-
|
|
233
|
-
function formatResult(data) {
|
|
234
|
-
// Construct configuration string, " A=a, B=b, ..."
|
|
235
|
-
let conf = '';
|
|
236
|
-
for (const key of Object.keys(data.conf)) {
|
|
237
|
-
conf += ` ${key}=${JSON.stringify(data.conf[key])}`;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
var rate = data.rate.toString().split('.');
|
|
241
|
-
rate[0] = rate[0].replace(/(\d)(?=(?:\d\d\d)+(?!\d))/g, '$1,');
|
|
242
|
-
rate = (rate[1] ? rate.join('.') : rate[0]);
|
|
243
|
-
|
|
244
|
-
var gcInfo;
|
|
245
|
-
gcInfo = `(minor: ${data.gcStats[NODE_PERFORMANCE_GC_MINOR].count} - ${data.gcStats[NODE_PERFORMANCE_GC_MINOR].totalDuration}ms,`;
|
|
246
|
-
gcInfo += ` major: ${data.gcStats[NODE_PERFORMANCE_GC_MAJOR].count} - ${data.gcStats[NODE_PERFORMANCE_GC_MAJOR].totalDuration}ms,`;
|
|
247
|
-
gcInfo += ` incremental: ${data.gcStats[NODE_PERFORMANCE_GC_INCREMENTAL].count} - ${data.gcStats[NODE_PERFORMANCE_GC_INCREMENTAL].totalDuration}ms)`;
|
|
248
|
-
|
|
249
|
-
return `${data.name}${conf}: ${rate} ${gcInfo}`;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
function sendResult(data) {
|
|
253
|
-
if (process.send) {
|
|
254
|
-
// If forked, report by process send
|
|
255
|
-
process.send(data);
|
|
256
|
-
} else {
|
|
257
|
-
// Otherwise report by stdout
|
|
258
|
-
console.log(formatResult(data));
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
Benchmark.prototype.report = function(rate, elapsed) {
|
|
263
|
-
sendResult({
|
|
264
|
-
name: this.name,
|
|
265
|
-
conf: this.config,
|
|
266
|
-
rate: rate,
|
|
267
|
-
time: elapsed[0] + elapsed[1] / 1e9,
|
|
268
|
-
type: 'report',
|
|
269
|
-
gcStats: this._gcStats
|
|
270
|
-
});
|
|
271
|
-
};
|
|
272
|
-
|
|
273
|
-
function createBenchmark(fn, configs, options) {
|
|
274
|
-
return new Benchmark(fn, configs, options);
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
function createConnection(cb) {
|
|
278
|
-
var config = JSON.parse(fs.readFileSync(require('os').homedir() + '/.tedious/test-connection.json', 'utf8')).config;
|
|
279
|
-
|
|
280
|
-
var connection = new Connection(config);
|
|
281
|
-
connection.connect(function() {
|
|
282
|
-
cb(connection);
|
|
283
|
-
});
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
module.exports.createBenchmark = createBenchmark;
|
|
287
|
-
module.exports.createConnection = createConnection;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
const { createBenchmark, createConnection } = require('../common');
|
|
2
|
-
|
|
3
|
-
const bench = createBenchmark(main, {
|
|
4
|
-
n: [10, 100]
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
function main({ n }) {
|
|
8
|
-
let i = 0;
|
|
9
|
-
bench.start();
|
|
10
|
-
|
|
11
|
-
(function cb() {
|
|
12
|
-
createConnection(function(connection) {
|
|
13
|
-
connection.close();
|
|
14
|
-
|
|
15
|
-
if (i++ === n) {
|
|
16
|
-
bench.end(n);
|
|
17
|
-
|
|
18
|
-
connection.close();
|
|
19
|
-
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
cb();
|
|
24
|
-
});
|
|
25
|
-
})();
|
|
26
|
-
}
|