Skip to content

Commit b32ec5c

Browse files
committed
Measure how long it takes to call Node.js for TypeScript generation.
1 parent b249296 commit b32ec5c

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

src/HtmlGenerator/Pass1-Generation/TypeScriptSupport.cs

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public void Generate(IEnumerable<string> typeScriptFiles)
3131
var list = new List<string>();
3232
string libFile = null;
3333

34-
foreach(var file in typeScriptFiles)
34+
foreach (var file in typeScriptFiles)
3535
{
3636
if (!alreadyProcessed.Contains(file))
3737
{
@@ -95,7 +95,10 @@ private void GenerateCore(IEnumerable<string> fileNames, string libFile)
9595
ProcessLaunchService.ProcessRunResult result;
9696
try
9797
{
98-
result = new ProcessLaunchService().RunAndRedirectOutput("node", arguments);
98+
using (Disposable.Timing("Calling Node.js to process TypeScript"))
99+
{
100+
result = new ProcessLaunchService().RunAndRedirectOutput("node", arguments);
101+
}
99102
}
100103
catch (Win32Exception)
101104
{
@@ -104,24 +107,27 @@ private void GenerateCore(IEnumerable<string> fileNames, string libFile)
104107
return;
105108
}
106109

107-
foreach (var file in Directory.GetFiles(output))
110+
using (Disposable.Timing("Generating TypeScript files"))
108111
{
109-
if (Path.GetFileNameWithoutExtension(file) == "ok")
112+
foreach (var file in Directory.GetFiles(output))
110113
{
111-
continue;
112-
}
114+
if (Path.GetFileNameWithoutExtension(file) == "ok")
115+
{
116+
continue;
117+
}
113118

114-
if (Path.GetFileNameWithoutExtension(file) == "error")
115-
{
116-
var errorContent = File.ReadAllText(file);
117-
Log.Exception(DateTime.Now.ToString() + " " + errorContent);
118-
return;
119-
}
119+
if (Path.GetFileNameWithoutExtension(file) == "error")
120+
{
121+
var errorContent = File.ReadAllText(file);
122+
Log.Exception(DateTime.Now.ToString() + " " + errorContent);
123+
return;
124+
}
120125

121-
var text = File.ReadAllText(file);
122-
AnalyzedFile analysis = JsonConvert.DeserializeObject<AnalyzedFile>(text);
126+
var text = File.ReadAllText(file);
127+
AnalyzedFile analysis = JsonConvert.DeserializeObject<AnalyzedFile>(text);
123128

124-
EnsureFileGeneratedAndGetUrl(analysis);
129+
EnsureFileGeneratedAndGetUrl(analysis);
130+
}
125131
}
126132
}
127133

0 commit comments

Comments
 (0)