Skip to content

Commit d206046

Browse files
authored
Collect timing information for commands running on travis (microsoft#10308)
1 parent ec49525 commit d206046

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

Jakefile.js

+32-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,28 @@ if (process.env.path !== undefined) {
3333
process.env.PATH = nodeModulesPathPrefix + process.env.PATH;
3434
}
3535

36+
function toNs(diff) {
37+
return diff[0] * 1e9 + diff[1];
38+
}
39+
40+
function mark() {
41+
if (!fold.isTravis()) return;
42+
var stamp = process.hrtime();
43+
var id = Math.floor(Math.random() * 0xFFFFFFFF).toString(16);
44+
console.log("travis_time:start:" + id + "\r");
45+
return {
46+
stamp: stamp,
47+
id: id
48+
};
49+
}
50+
51+
function measure(marker) {
52+
if (!fold.isTravis()) return;
53+
var diff = process.hrtime(marker.stamp);
54+
var total = [marker.stamp[0] + diff[0], marker.stamp[1] + diff[1]];
55+
console.log("travis_time:end:" + marker.id + ":start=" + toNs(marker.stamp) + ",finish=" + toNs(total) + ",duration=" + toNs(diff) + "\r");
56+
}
57+
3658
var compilerSources = [
3759
"core.ts",
3860
"performance.ts",
@@ -286,6 +308,7 @@ var builtLocalCompiler = path.join(builtLocalDirectory, compilerFilename);
286308
*/
287309
function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts, callback) {
288310
file(outFile, prereqs, function() {
311+
var startCompileTime = mark();
289312
opts = opts || {};
290313
var compilerPath = useBuiltCompiler ? builtLocalCompiler : LKGCompiler;
291314
var options = "--noImplicitAny --noImplicitThis --noEmitOnError --types "
@@ -362,11 +385,13 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts
362385
callback();
363386
}
364387

388+
measure(startCompileTime);
365389
complete();
366390
});
367391
ex.addListener("error", function() {
368392
fs.unlinkSync(outFile);
369393
fail("Compilation of " + outFile + " unsuccessful");
394+
measure(startCompileTime);
370395
});
371396
ex.run();
372397
}, {async: true});
@@ -769,6 +794,7 @@ function runConsoleTests(defaultReporter, runInParallel) {
769794
// timeout normally isn't necessary but Travis-CI has been timing out on compiler baselines occasionally
770795
// default timeout is 2sec which really should be enough, but maybe we just need a small amount longer
771796
if(!runInParallel) {
797+
var startTime = mark();
772798
tests = tests ? ' -g "' + tests + '"' : '';
773799
var cmd = "mocha" + (debug ? " --debug-brk" : "") + " -R " + reporter + tests + colors + bail + ' -t ' + testTimeout + ' ' + run;
774800
console.log(cmd);
@@ -777,20 +803,23 @@ function runConsoleTests(defaultReporter, runInParallel) {
777803
process.env.NODE_ENV = "development";
778804
exec(cmd, function () {
779805
process.env.NODE_ENV = savedNodeEnv;
806+
measure(startTime);
780807
runLinter();
781808
finish();
782809
}, function(e, status) {
783810
process.env.NODE_ENV = savedNodeEnv;
811+
measure(startTime);
784812
finish(status);
785813
});
786814

787815
}
788816
else {
789817
var savedNodeEnv = process.env.NODE_ENV;
790818
process.env.NODE_ENV = "development";
819+
var startTime = mark();
791820
runTestsInParallel(taskConfigsFolder, run, { testTimeout: testTimeout, noColors: colors === " --no-colors " }, function (err) {
792821
process.env.NODE_ENV = savedNodeEnv;
793-
822+
measure(startTime);
794823
// last worker clean everything and runs linter in case if there were no errors
795824
deleteTemporaryProjectOutput();
796825
jake.rmRf(taskConfigsFolder);
@@ -1069,6 +1098,7 @@ var lintTargets = compilerSources
10691098
desc("Runs tslint on the compiler sources. Optional arguments are: f[iles]=regex");
10701099
task("lint", ["build-rules"], function() {
10711100
if (fold.isTravis()) console.log(fold.start("lint"));
1101+
var startTime = mark();
10721102
var lintOptions = getLinterOptions();
10731103
var failed = 0;
10741104
var fileMatcher = RegExp(process.env.f || process.env.file || process.env.files || "");
@@ -1084,6 +1114,7 @@ task("lint", ["build-rules"], function() {
10841114
done[target] = true;
10851115
}
10861116
}
1117+
measure(startTime);
10871118
if (fold.isTravis()) console.log(fold.end("lint"));
10881119
if (failed > 0) {
10891120
fail('Linter errors.', failed);

0 commit comments

Comments
 (0)