Comparing version 7.0.0-alpha.5 to 7.0.0-alpha.6
'use strict' | ||
const { Writable } = require('node:stream') | ||
const { nowAbsolute } = require('../util/timers.js') | ||
@@ -80,3 +79,3 @@ /** | ||
const now = nowAbsolute() | ||
const now = Date.now() | ||
const entry = this.#entries.get(topLevelKey)?.find((entry) => ( | ||
@@ -83,0 +82,0 @@ entry.deleteAt > now && |
@@ -10,3 +10,2 @@ 'use strict' | ||
} = require('../util/cache') | ||
const { nowAbsolute } = require('../util/timers.js') | ||
@@ -127,3 +126,3 @@ function noop () {} | ||
const now = nowAbsolute() | ||
const now = Date.now() | ||
const staleAt = determineStaleAt(now, headers, cacheControlDirectives) | ||
@@ -316,3 +315,3 @@ if (staleAt) { | ||
if (expiresDate instanceof Date && !isNaN(expiresDate)) { | ||
return now + (nowAbsolute() - expiresDate.getTime()) | ||
return now + (Date.now() - expiresDate.getTime()) | ||
} | ||
@@ -319,0 +318,0 @@ } |
@@ -10,3 +10,2 @@ 'use strict' | ||
const { assertCacheStore, assertCacheMethods, makeCacheKey, parseCacheControlHeader } = require('../util/cache.js') | ||
const { nowAbsolute } = require('../util/timers.js') | ||
@@ -60,3 +59,3 @@ const AGE_HEADER = Buffer.from('age') | ||
const now = nowAbsolute() | ||
const now = Date.now() | ||
if (now > result.staleAt) { | ||
@@ -191,2 +190,3 @@ // Response is stale | ||
// https://www.rfc-editor.org/rfc/rfc9111.html#name-age | ||
const age = Math.round((Date.now() - result.cachedAt) / 1000) | ||
@@ -222,3 +222,3 @@ // TODO (fix): What if rawHeaders already contains age header? | ||
const age = Math.round((nowAbsolute() - result.cachedAt) / 1000) | ||
const age = Math.round((Date.now() - result.cachedAt) / 1000) | ||
if (requestCacheControl?.['max-age'] && age >= requestCacheControl['max-age']) { | ||
@@ -225,0 +225,0 @@ // Response is considered expired for this specific request |
@@ -355,5 +355,11 @@ 'use strict' | ||
const dispatchOpts = { | ||
let dispatchOpts = null | ||
dispatchOpts = { | ||
...origDispatchOpts, | ||
origin: newOrigin | ||
servername: origin.hostname, // For SNI on TLS | ||
origin: newOrigin, | ||
headers: { | ||
host: origin.hostname, | ||
...origDispatchOpts.headers | ||
} | ||
} | ||
@@ -360,0 +366,0 @@ |
@@ -25,9 +25,2 @@ 'use strict' | ||
/** | ||
* The fastNowAbsolute variable contains the rough result of Date.now() | ||
* | ||
* @type {number} | ||
*/ | ||
let fastNowAbsolute = Date.now() | ||
/** | ||
* RESOLUTION_MS represents the target resolution time in milliseconds. | ||
@@ -133,4 +126,2 @@ * | ||
fastNowAbsolute = Date.now() | ||
/** | ||
@@ -404,5 +395,2 @@ * The `idx` variable is used to iterate over the `fastTimers` array. | ||
}, | ||
nowAbsolute () { | ||
return fastNowAbsolute | ||
}, | ||
/** | ||
@@ -437,9 +425,3 @@ * Trigger the onTick function to process the fastTimers array. | ||
*/ | ||
kFastTimer, | ||
/** | ||
* Exporting for testing purposes only. | ||
* Marking as deprecated to discourage any use outside of testing. | ||
* @deprecated | ||
*/ | ||
RESOLUTION_MS | ||
kFastTimer | ||
} |
{ | ||
"name": "undici", | ||
"version": "7.0.0-alpha.5", | ||
"version": "7.0.0-alpha.6", | ||
"description": "An HTTP/1.1 client, written from scratch for Node.js", | ||
@@ -5,0 +5,0 @@ "homepage": "https://undici.nodejs.org", |
@@ -25,38 +25,23 @@ # undici | ||
The benchmark is a simple getting data [example](https://github.com/nodejs/undici/blob/main/benchmarks/benchmark.js) using a | ||
50 TCP connections with a pipelining depth of 10 running on Node 20.10.0. | ||
50 TCP connections with a pipelining depth of 10 running on Node 22.11.0. | ||
| _Tests_ | _Samples_ | _Result_ | _Tolerance_ | _Difference with slowest_ | | ||
| :-----------------: | :-------: | :--------------: | :---------: | :-----------------------: | | ||
| undici - fetch | 30 | 3704.43 req/sec | ± 2.95 % | - | | ||
| http - no keepalive | 20 | 4275.30 req/sec | ± 2.60 % | + 15.41 % | | ||
| node-fetch | 10 | 4759.42 req/sec | ± 0.87 % | + 28.48 % | | ||
| request | 40 | 4803.37 req/sec | ± 2.77 % | + 29.67 % | | ||
| axios | 45 | 4951.97 req/sec | ± 2.88 % | + 33.68 % | | ||
| got | 10 | 5969.67 req/sec | ± 2.64 % | + 61.15 % | | ||
| superagent | 10 | 9471.48 req/sec | ± 1.50 % | + 155.68 % | | ||
| http - keepalive | 25 | 10327.49 req/sec | ± 2.95 % | + 178.79 % | | ||
| undici - pipeline | 10 | 15053.41 req/sec | ± 1.63 % | + 306.36 % | | ||
| undici - request | 10 | 19264.24 req/sec | ± 1.74 % | + 420.03 % | | ||
| undici - stream | 15 | 20317.29 req/sec | ± 2.13 % | + 448.46 % | | ||
| undici - dispatch | 10 | 24883.28 req/sec | ± 1.54 % | + 571.72 % | | ||
``` | ||
┌────────────────────────┬─────────┬────────────────────┬────────────┬─────────────────────────┐ | ||
│ Tests │ Samples │ Result │ Tolerance │ Difference with slowest │ | ||
├────────────────────────┼─────────┼────────────────────┼────────────┼─────────────────────────┤ | ||
│ 'axios' │ 15 │ '5708.26 req/sec' │ '± 2.91 %' │ '-' │ | ||
│ 'http - no keepalive' │ 10 │ '5809.80 req/sec' │ '± 2.30 %' │ '+ 1.78 %' │ | ||
│ 'request' │ 30 │ '5828.80 req/sec' │ '± 2.91 %' │ '+ 2.11 %' │ | ||
│ 'undici - fetch' │ 40 │ '5903.78 req/sec' │ '± 2.87 %' │ '+ 3.43 %' │ | ||
│ 'node-fetch' │ 10 │ '5945.40 req/sec' │ '± 2.13 %' │ '+ 4.15 %' │ | ||
│ 'got' │ 35 │ '6511.45 req/sec' │ '± 2.84 %' │ '+ 14.07 %' │ | ||
│ 'http - keepalive' │ 65 │ '9193.24 req/sec' │ '± 2.92 %' │ '+ 61.05 %' │ | ||
│ 'superagent' │ 35 │ '9339.43 req/sec' │ '± 2.95 %' │ '+ 63.61 %' │ | ||
│ 'undici - pipeline' │ 50 │ '13364.62 req/sec' │ '± 2.93 %' │ '+ 134.13 %' │ | ||
│ 'undici - stream' │ 95 │ '18245.36 req/sec' │ '± 2.99 %' │ '+ 219.63 %' │ | ||
│ 'undici - request' │ 50 │ '18340.17 req/sec' │ '± 2.84 %' │ '+ 221.29 %' │ | ||
│ 'undici - dispatch' │ 40 │ '22234.42 req/sec' │ '± 2.94 %' │ '+ 289.51 %' │ | ||
└────────────────────────┴─────────┴────────────────────┴────────────┴─────────────────────────┘ | ||
``` | ||
The benchmark is a simple sending data [example](https://github.com/nodejs/undici/blob/main/benchmarks/post-benchmark.js) using a | ||
50 TCP connections with a pipelining depth of 10 running on Node 20.10.0. | ||
| _Tests_ | _Samples_ | _Result_ | _Tolerance_ | _Difference with slowest_ | | ||
| :-----------------: | :-------: | :-------------: | :---------: | :-----------------------: | | ||
| undici - fetch | 20 | 1968.42 req/sec | ± 2.63 % | - | | ||
| http - no keepalive | 25 | 2330.30 req/sec | ± 2.99 % | + 18.38 % | | ||
| node-fetch | 20 | 2485.36 req/sec | ± 2.70 % | + 26.26 % | | ||
| got | 15 | 2787.68 req/sec | ± 2.56 % | + 41.62 % | | ||
| request | 30 | 2805.10 req/sec | ± 2.59 % | + 42.50 % | | ||
| axios | 10 | 3040.45 req/sec | ± 1.72 % | + 54.46 % | | ||
| superagent | 20 | 3358.29 req/sec | ± 2.51 % | + 70.61 % | | ||
| http - keepalive | 20 | 3477.94 req/sec | ± 2.51 % | + 76.69 % | | ||
| undici - pipeline | 25 | 3812.61 req/sec | ± 2.80 % | + 93.69 % | | ||
| undici - request | 10 | 6067.00 req/sec | ± 0.94 % | + 208.22 % | | ||
| undici - stream | 10 | 6391.61 req/sec | ± 1.98 % | + 224.71 % | | ||
| undici - dispatch | 10 | 6397.00 req/sec | ± 1.48 % | + 224.98 % | | ||
## Quick Start | ||
@@ -63,0 +48,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1263304
27060
449