+'use strict'
/**
- * The worker function to execute during pools benchmarks.
- * NOTE: This function requires to be self-contained, thread-safe and re-entrant.
+ * The task function to execute during pools benchmarks.
+ * NOTE: This function requires to be self-contained, thread-safe and re-entrant (node-worker-threads-pool requirement).
* @param {*} data The worker data.
* @returns {*} The result.
*/
-module.exports = function functionToBench (data) {
- const crypto = require('crypto')
- const fs = require('fs')
+const functionToBench = data => {
+ const crypto = require('node:crypto')
+ const fs = require('node:fs')
const TaskTypes = {
CPU_INTENSIVE: 'CPU_INTENSIVE',
IO_INTENSIVE: 'IO_INTENSIVE'
throw new Error(`Unknown task type: ${data.taskType}`)
}
}
+
+module.exports = functionToBench