Skip to content

Commit

Permalink
To optimize #53
Browse files Browse the repository at this point in the history
  • Loading branch information
Samchon committed Dec 11, 2019
1 parent 92bc8c2 commit 8c2d1cd
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"email": "samchon@samchon.org",
"url": "http://samchon.org"
},
"version": "2.4.0-dev.20191211",
"version": "2.4.0-dev.20191212",
"main": "./index.js",
"typings": "./index.d.ts",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/test/container/test_trees.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function test_trees(): void

function _Test_tree_set_inserts_and_erases(): void
{
for (let k = 0; k < 1000; ++k)
for (let k = 0; k < 100; ++k)
{
let set: std.TreeSet<number> = new std.TreeSet();
for (let i = 0; i < 100; ++i)
Expand Down
39 changes: 27 additions & 12 deletions src/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ interface IModule
[key: string]: ()=>Promise<void>;
}

async function measure(job: ()=>Promise<void>): Promise<number>
{
let time: number = Date.now();
await job();

return Date.now() - time;
}

async function iterate(path: string): Promise<void>
{
let file_list: string[] = fs.readdirSync(path);
Expand All @@ -26,16 +34,19 @@ async function iterate(path: string): Promise<void>

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

// DO TEST
console.log(key);
await external[key]();
}
// PRINT TITLE & ELAPSED TIME
process.stdout.write(" - " + key);

let time: number = await measure(() => external[key]());
console.log(`: ${StringUtil.numberFormat(time)} ms`);
}
}
}

Expand All @@ -44,16 +55,19 @@ async function main(): Promise<void>
//----
// DO TEST
//----
let time: number = Date.now();
await iterate(PATH);
console.log("==========================================================");
console.log(" TSTL Test Automation Program");
console.log("==========================================================");

let time: number = await measure(() => iterate(PATH));

//----
// TRACE BENCHMARK
//----
// ELAPSED TIME
console.log("----------------------------------------------------------");
console.log("Success");
console.log(` - elapsed time: ${StringUtil.numberFormat(Date.now() - time)} ms`);
console.log(` - elapsed time: ${StringUtil.numberFormat(time)} ms`);

// MEMORY USAGE
let memory: NodeJS.MemoryUsage = process.memoryUsage();
Expand All @@ -62,6 +76,7 @@ async function main(): Promise<void>
let amount: number = memory[property as keyof NodeJS.MemoryUsage] / 10**6;
console.log(` - ${property}: ${StringUtil.numberFormat(amount)} MB`);
}
console.log("----------------------------------------------------------\n");
}
main().catch(e =>
{
Expand Down
2 changes: 1 addition & 1 deletion src/test/internal/Atomic.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as std from "../../index";
import std = require("../..");

export class Atomic<T> implements std.IPointer<T>, std.IComparable<Atomic<T>>
{
Expand Down
2 changes: 1 addition & 1 deletion src/test/internal/Point2D.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as std from "../../index";
import std = require("../..");

export class Point2D
implements Pick<std.IComparable<Point2D>, "equals">,
Expand Down

0 comments on commit 8c2d1cd

Please sign in to comment.