Skip to content
Permalink
Browse files

Retry #60

  • Loading branch information
samchon committed Feb 8, 2020
1 parent 5867c52 commit aba8b67b7036b0c579af6380a0dba30070ff86c2
@@ -9,6 +9,7 @@ assets/
node_modules/
build/
src/
test/
benchmark/

*.log
@@ -8,13 +8,19 @@
"type": "node",
"request": "launch",
"name": "Launch Program",
"runtimeArgs": [
"-r",
"ts-node/register"
],
"args": [
"${workspaceRoot}/src/test/index.ts"
]
"program": "${workspaceRoot}/test/index.js",
"cwd": "${workspaceRoot}",

// TypeScript
"sourceMaps": true,
"outFiles": ["${workspaceRot}/**.js"]
},
{
"type": "node",
"request": "attach",
"name": "Attach to Process",
"port": 5858,
"outFiles": []
}
]
}

Large diffs are not rendered by default.

@@ -15,13 +15,15 @@
"build": "npm run module && npm run compile && npm run test",
"clean": "node build/clean",
"compile": "tsc",
"module": "tsc -p module.json",
"dev": "tsc --watch",
"test": "ts-node src/test"
"module": "tsc -p module.json",
"test": "node test"
},
"devDependencies": {
"@types/node": "^11.13.14",
"ts-node": "^8.6.2",
"@types/cli": "^0.11.19",
"@types/node": "^13.7.0",
"cli": "^1.0.1",
"source-map-support": "^0.5.16",
"typedoc": "^0.14.2",
"typedoc-plugin-external-module-name": "^2.0.0",
"typescript": "^3.7.5"
@@ -1,3 +1,4 @@
import "source-map-support/register";
import { FileSystem } from "./internal/FileSystem";

interface IModule
@@ -1,8 +1,14 @@
import * as fs from "fs";
import { StringUtil } from "../benchmark/internal/StringUtil";
import "source-map-support/register";
import cli from "cli";
import fs from "fs";

const PATH = __dirname;
import { StringUtil } from "../benchmark/internal/StringUtil";

interface ICommand
{
target?: string;
exclude?: string;
}
interface IModule
{
[key: string]: ()=>Promise<void>;
@@ -16,36 +22,43 @@ async function measure(job: ()=>Promise<void>): Promise<number>
return Date.now() - time;
}

async function iterate(path: string): Promise<void>
async function iterate(command: ICommand, path: string): Promise<void>
{
let file_list: string[] = fs.readdirSync(path);
for (let file of file_list)
let fileList: string[] = fs.readdirSync(path);
for (let file of fileList)
{
let current_path: string = path + "/" + file;
let stat: fs.Stats = fs.lstatSync(current_path);
let currentPath: string = path + "/" + file;
let stat: fs.Stats = fs.lstatSync(currentPath);

if (stat.isDirectory() === true && file !== "internal")
{
await iterate(current_path);
await iterate(command, currentPath);
continue;
}
else if (file.substr(-3) !== ".ts" || current_path === `${PATH}/index.ts`)
else if (file.substr(-3) !== ".js" || currentPath === `${__dirname}/index.js`)
continue;
else if (file.substr(0, 5) !== "test_")
continue;

let moduleName: string = file.substring(5, file.length - 3);
if (command.exclude && command.exclude === moduleName)
continue;
if (command.target && command.target !== moduleName)
continue;

let external: IModule = await import(current_path.substr(0, current_path.length - 3));
let time: number = Date.now();
let external: IModule = await import(currentPath.substr(0, currentPath.length - 3));
for (let key in external)
{
// WHETHER TESTING TARGET OR NOT
if (key.substr(0, 5) !== "test_")
continue;
else if (process.argv[2] && key.replace("test_", "") !== process.argv[2])
continue;


// PRINT TITLE & ELAPSED TIME
process.stdout.write(" - " + key);

let time: number = await measure(() => external[key]());
console.log(`: ${StringUtil.numberFormat(time)} ms`);
await external[key]();
console.log(`: ${StringUtil.numberFormat(Date.now() - time)} ms`);
}
}
}
@@ -59,7 +72,11 @@ async function main(): Promise<void>
console.log(" TSTL Test Automation Program");
console.log("==========================================================");

let time: number = await measure(() => iterate(PATH));
let command: ICommand = cli.parse();
if (process.argv[2] && process.argv[2][0] !== '-')
command.target = process.argv[2];

let time: number = await measure(() => iterate(command, __dirname));

//----
// TRACE BENCHMARK

0 comments on commit aba8b67

Please sign in to comment.
You can’t perform that action at this time.