testdriverai 4.0.63 → 4.0.65

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/index.js CHANGED
@@ -1,4 +1,21 @@
1
1
  #!/usr/bin/env node
2
+ const os = require('os');
3
+
4
+ // Get the current process ID
5
+ const pid = process.pid;
6
+
7
+ try {
8
+ // Display the current priority
9
+ console.log('Current priority:', os.getPriority(pid));
10
+
11
+ // Set the priority to the highest value
12
+ os.setPriority(pid, -20);
13
+
14
+ // Display the updated priority
15
+ console.log('Updated priority:', os.getPriority(pid));
16
+ } catch (error) {
17
+ console.error('Failed to set process priority:', error);
18
+ }
2
19
 
3
20
  // disable depreciation warnings
4
21
  process.removeAllListeners("warning");
@@ -11,7 +28,6 @@ require("./lib/profiler");
11
28
 
12
29
  const fs = require("fs");
13
30
  const readline = require("readline");
14
- const os = require("os");
15
31
  const http = require('http');
16
32
 
17
33
  // third party modules
package/lib/config.js CHANGED
@@ -28,6 +28,7 @@ const config = {
28
28
  TD_MINIMIZE: false,
29
29
  TD_API_ROOT: "https://replayable-api-production.herokuapp.com",
30
30
  TD_DEV: parseValue(process.env["DEV"]),
31
+ TD_PROFILE: false,
31
32
  };
32
33
 
33
34
  // Find all env vars starting with TD_
package/lib/profiler.js CHANGED
@@ -1,6 +1,7 @@
1
1
  // globalTracer.js
2
2
 
3
- const chalk = require('chalk');
3
+ const chalk = require("chalk");
4
+ const config = require("./config.js");
4
5
 
5
6
  // Save the original function prototype's apply method
6
7
  const originalApply = Function.prototype.apply;
@@ -15,11 +16,12 @@ function isProjectFunction() {
15
16
 
16
17
  // Override the apply method to add tracing and timing for project functions only
17
18
  Function.prototype.apply = function (thisArg, argsArray) {
18
- const functionName = this.name || 'anonymous function';
19
+ const functionName = this.name || "anonymous function";
19
20
 
20
21
  // Only trace named functions defined in the user's files
21
22
  if (functionName && isProjectFunction()) {
22
- console.log(chalk.cyan(`[profiler] called: ${functionName}`));
23
+ if (config.TD_PROFILE)
24
+ console.log(chalk.cyan(`[profiler] called: ${functionName}`));
23
25
 
24
26
  // Start the timer
25
27
  const startTime = process.hrtime();
@@ -29,14 +31,23 @@ Function.prototype.apply = function (thisArg, argsArray) {
29
31
 
30
32
  // End the timer and calculate the elapsed time
31
33
  const [seconds, nanoseconds] = process.hrtime(startTime);
32
- const elapsedMilliseconds = (seconds * 1000) + (nanoseconds / 1e6);
34
+ const elapsedMilliseconds = seconds * 1000 + nanoseconds / 1e6;
33
35
 
34
36
  // Log the elapsed time
35
- console.log(chalk.green(`[profiler] ${functionName} execution time: ${elapsedMilliseconds.toFixed(3)} ms`));
37
+ if (config.TD_PROFILE)
38
+ console.log(
39
+ chalk.green(
40
+ `[profiler] ${functionName} execution time: ${elapsedMilliseconds.toFixed(3)} ms`,
41
+ ),
42
+ );
36
43
 
37
44
  // Check if the execution time exceeds the maximum threshold
38
45
  if (elapsedMilliseconds > MAX_EXECUTION_TIME_MS) {
39
- console.error(chalk.red(`[profiler] Error: Function ${functionName} took too long to execute (${elapsedMilliseconds.toFixed(3)} ms)`));
46
+ console.error(
47
+ chalk.red(
48
+ `[profiler] Error: Function ${functionName} took too long to execute (${elapsedMilliseconds.toFixed(3)} ms)`,
49
+ ),
50
+ );
40
51
  }
41
52
 
42
53
  return result;
@@ -46,4 +57,9 @@ Function.prototype.apply = function (thisArg, argsArray) {
46
57
  }
47
58
  };
48
59
 
49
- console.log(chalk.yellow('Global function tracing with timing and error logging for project-defined functions is enabled.'));
60
+ if (config.TD_PROFILE)
61
+ console.log(
62
+ chalk.yellow(
63
+ "Global function tracing with timing and error logging for project-defined functions is enabled.",
64
+ ),
65
+ );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testdriverai",
3
- "version": "4.0.63",
3
+ "version": "4.0.65",
4
4
  "description": "Next generation autonomous AI agent for end-to-end testing of web & desktop",
5
5
  "main": "index.js",
6
6
  "bin": {