-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(jsii-reflect): don't load same assembly multiple times (#461)
deCDK tests were calling `loadModule()` for every package. `loadModule()` did have some recursion avoidance INSIDE one call, but not across multiple load calls on the same type system. This brings down the deCDK tests from 80s to 10s. Add an option to disable validation, which would bring the full CDK typesystem loading down from 10s to 600ms (validation is enabled by default). Some more type exposure updates so that we can update awslint and friends in the CDK repository to take advantage of the new jsii model. Also: change some JVM settings in pacmak to speed up Java build from around 30s to around 10s per package (on my machine, on my Oracle JVM, YYMV on OpenJDK).
- Loading branch information
Showing
13 changed files
with
196 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/** | ||
* A single timer | ||
*/ | ||
export class Timer { | ||
public timeMs?: number; | ||
private startTime: number; | ||
|
||
constructor(public readonly label: string) { | ||
this.startTime = Date.now(); | ||
} | ||
|
||
public start() { | ||
this.startTime = Date.now(); | ||
} | ||
|
||
public end() { | ||
this.timeMs = (Date.now() - this.startTime) / 1000; | ||
} | ||
|
||
public isSet() { | ||
return this.timeMs !== undefined; | ||
} | ||
|
||
public humanTime() { | ||
if (!this.timeMs) { return '???'; } | ||
|
||
const parts = []; | ||
|
||
let time = this.timeMs; | ||
if (time > 60) { | ||
const mins = Math.floor(time / 60); | ||
parts.push(mins + 'm'); | ||
time -= mins * 60; | ||
} | ||
parts.push(time.toFixed(1) + 's'); | ||
|
||
return parts.join(''); | ||
} | ||
} | ||
|
||
/** | ||
* A collection of Timers | ||
*/ | ||
export class Timers { | ||
private readonly timers: Timer[] = []; | ||
|
||
public record<T>(label: string, operation: () => T): T { | ||
const timer = this.start(label); | ||
try { | ||
const x = operation(); | ||
timer.end(); | ||
return x; | ||
} catch (e) { | ||
timer.end(); | ||
throw e; | ||
} | ||
} | ||
|
||
public async recordAsync<T>(label: string, operation: () => Promise<T>) { | ||
const timer = this.start(label); | ||
try { | ||
const x = await operation(); | ||
timer.end(); | ||
return x; | ||
} catch (e) { | ||
timer.end(); | ||
throw e; | ||
} | ||
} | ||
|
||
public start(label: string) { | ||
const timer = new Timer(label); | ||
this.timers.push(timer); | ||
return timer; | ||
} | ||
|
||
public display(): string { | ||
const timers = this.timers.filter(t => t.isSet()); | ||
timers.sort((a: Timer, b: Timer) => b.timeMs! - a.timeMs!); | ||
return timers.map(t => `${t.label} (${t.humanTime()})`).join(' | '); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters