perf: use node: prefix to bypass caching call for builtins
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Mon, 11 Sep 2023 21:02:17 +0000 (23:02 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Mon, 11 Sep 2023 21:02:17 +0000 (23:02 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
12 files changed:
benchmarks/internal/cluster-worker.mjs
benchmarks/internal/thread-worker.mjs
benchmarks/versus-external-pools/functions/function-to-bench.js
examples/javascript/yourWorker.js
examples/typescript/http-server-pool/express-cluster/src/worker.ts
examples/typescript/http-server-pool/express-hybrid/src/express-worker.ts
examples/typescript/http-server-pool/fastify-hybrid/src/fastify-poolifier.ts
examples/typescript/http-server-pool/fastify-worker_threads/src/fastify-poolifier.ts
examples/typescript/pool.ts
tests/pools/abstract/abstract-pool.test.js
tests/pools/abstract/worker-node.test.js
tests/utils.test.js

index f6b3b056ea37d0eb3b6bb76242c7e0d983654b2d..69a7ad15cae0ada671f3e4f8ef1261305d26e51a 100644 (file)
@@ -1,4 +1,4 @@
-import { isPrimary } from 'cluster'
+import { isPrimary } from 'node:cluster'
 import { ClusterWorker } from '../../lib/index.mjs'
 import { executeTaskFunction } from '../benchmarks-utils.mjs'
 import { TaskFunctions } from '../benchmarks-types.mjs'
index 94250a3abae973fa06f62d09ca904ddd0ac97a19..7af5fa638aed36a25bba7c384d95c8b604eac5ba 100644 (file)
@@ -1,4 +1,4 @@
-import { isMainThread } from 'worker_threads'
+import { isMainThread } from 'node:worker_threads'
 import { ThreadWorker } from '../../lib/index.mjs'
 import { executeTaskFunction } from '../benchmarks-utils.mjs'
 import { TaskFunctions } from '../benchmarks-types.mjs'
index ecc39a1c92be59327bd6b7d9d141c8bbf485b4be..ff13bc9ecd2ad04fb034bab8a622198ad748e10a 100644 (file)
@@ -6,8 +6,8 @@
  * @returns {*} The result.
  */
 const functionToBench = data => {
-  const crypto = require('crypto')
-  const fs = require('fs')
+  const crypto = require('node:crypto')
+  const fs = require('node:fs')
   const TaskTypes = {
     CPU_INTENSIVE: 'CPU_INTENSIVE',
     IO_INTENSIVE: 'IO_INTENSIVE'
index c21f911dc54a502490c3e4e5684af972f6180041..cc462f7f97b1cde5a48712494a651fcf90f420fb 100644 (file)
@@ -1,5 +1,5 @@
 'use strict'
-const { isMainThread } = require('worker_threads')
+const { isMainThread } = require('node:worker_threads')
 const { ThreadWorker } = require('poolifier')
 
 const debug = false
index da1066c4a7d997e044af5731596ca08c36a251ed..c5fe74acc122c0c391d419c559d613026ea56354 100644 (file)
@@ -1,5 +1,5 @@
-import type { Server } from 'http'
-import type { AddressInfo } from 'net'
+import type { Server } from 'node:http'
+import type { AddressInfo } from 'node:net'
 import { ClusterWorker } from 'poolifier'
 import express, { type Express, type Request, type Response } from 'express'
 import { type WorkerData, type WorkerResponse } from './types.js'
index db05cdbeb0cc745bfe77b33ee200dc1d4d2ba835..c7ca23adee4a4c2c48ec5a06f9792f93d45438fe 100644 (file)
@@ -1,5 +1,5 @@
-import type { Server } from 'http'
-import type { AddressInfo } from 'net'
+import type { Server } from 'node:http'
+import type { AddressInfo } from 'node:net'
 import {
   ClusterWorker,
   DynamicThreadPool,
index 7426ed46f62300c701d20ddc9347bc5a58dd0b54..2d13758028f8105f893226d91ed1c8ff07482949 100644 (file)
@@ -1,4 +1,4 @@
-import type { TransferListItem } from 'worker_threads'
+import type { TransferListItem } from 'node:worker_threads'
 import { DynamicThreadPool, availableParallelism } from 'poolifier'
 import { type FastifyPluginCallback } from 'fastify'
 import fp from 'fastify-plugin'
index 85e22c12698cc8d3dbe2fb068c005e993ed8872f..74c0c1687a7ee3dd586e570f7968f623f84d42c7 100644 (file)
@@ -1,4 +1,4 @@
-import type { TransferListItem } from 'worker_threads'
+import type { TransferListItem } from 'node:worker_threads'
 import { DynamicThreadPool, availableParallelism } from 'poolifier'
 import { type FastifyPluginCallback } from 'fastify'
 import fp from 'fastify-plugin'
index 93774422b4500459715ec236c136c1601f13add4..3d9d9e6f482723cdb634e98bd02a9bbd46df3314 100644 (file)
@@ -1,5 +1,5 @@
-import { dirname, extname, join } from 'path'
-import { fileURLToPath } from 'url'
+import { dirname, extname, join } from 'node:path'
+import { fileURLToPath } from 'node:url'
 import type { MyData, MyResponse } from './worker'
 import {
   DynamicThreadPool,
index a206948f6d19b168f910b55f98ba09e488266204..bedb1c6c42a9121697990121185c049c26ed87a4 100644 (file)
@@ -1,4 +1,4 @@
-const { EventEmitter } = require('events')
+const { EventEmitter } = require('node:events')
 const { expect } = require('expect')
 const sinon = require('sinon')
 const {
index 4b325f4303dbe2692cc8a0437e55180158df3a2b..c57ce953fdf826be0811043cc292c340f47b5b8e 100644 (file)
@@ -1,5 +1,5 @@
-const { MessageChannel, Worker } = require('worker_threads')
-const cluster = require('cluster')
+const { MessageChannel, Worker } = require('node:worker_threads')
+const cluster = require('node:cluster')
 const { expect } = require('expect')
 const { WorkerNode } = require('../../../lib/pools/worker-node')
 const { WorkerTypes } = require('../../../lib')
index 426985a299b366997189217802e4fab4283f7a7e..5041f1028a49fcf598922aa307e481b94a8745a8 100644 (file)
@@ -1,7 +1,7 @@
-const { randomInt } = require('crypto')
-const { Worker } = require('worker_threads')
-const cluster = require('cluster')
-const os = require('os')
+const { randomInt } = require('node:crypto')
+const { Worker } = require('node:worker_threads')
+const cluster = require('node:cluster')
+const os = require('node:os')
 const { expect } = require('expect')
 const {
   CircularArray,