Skip to content

Commit a8da2d0

Browse files
authored
Display compile time after build (#1665)
Resolves #374 If build succeeds, output duration as default build system. ``` [Finished in 20.4s] ```
1 parent 1aec1c7 commit a8da2d0

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

LaTeXTools Build Output.sublime-syntax

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ version: 2
77
hidden: true
88

99
variables:
10-
build_results: ^\[(?:Build (?:cancelled by user|failed|skipped)|Done)!\]$
10+
build_results: ^\[(?:(?:Build (?:cancelled by user|failed|skipped))!|Finished in .+)\]$
1111
log_file: ^((.+?)(?:(:)(\d+))?)(:)[ ](Double-click here to open the full log\.)$
1212

1313
contexts:
@@ -106,5 +106,5 @@ contexts:
106106
scope: meta.summary.failure.build.latextools message.error.build.latextools
107107
- match: ^\[Build cancelled by user!\]$\n?
108108
scope: meta.summary.failure.build.latextools message.warning.build.latextools
109-
- match: ^\[(?:Build skipped|Done)!\]$\n?
109+
- match: ^\[(?:Build skipped!|Finished in .+)\]$\n?
110110
scope: meta.summary.success.build.latextools message.info.build.latextools

latextools/make_pdf.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import shutil
1414
import signal
1515
import threading
16+
import time
1617
import traceback
1718

1819
import sublime
@@ -60,6 +61,8 @@ def run(self):
6061
self.worker(activity_indicator)
6162

6263
def worker(self, activity_indicator):
64+
t1 = time.monotonic()
65+
6366
logger.debug(f"Welcome to thread {self.name}")
6467
self.caller.output(
6568
f"[Compiling '{self.caller.builder.tex_root}' with '{self.caller.builder.name}']\n"
@@ -306,7 +309,15 @@ def worker(self, activity_indicator):
306309
traceback.print_exc()
307310

308311
self.caller.output(content)
309-
self.caller.output("\n\n[Build failed!]" if aborted else "\n\n[Done!]")
312+
if aborted:
313+
self.caller.output("\n\n[Build failed!]")
314+
else:
315+
elapsed = time.monotonic() - t1
316+
if elapsed >= 60:
317+
elapsed = time.strftime("%M:%S", time.gmtime(elapsed))
318+
else:
319+
elapsed = f"{elapsed:0.1f}s"
320+
self.caller.output(f"\n\n[Finished in {elapsed}]")
310321

311322
self.caller.errors = errors
312323
self.caller.warnings = warnings

tests/syntax/syntax_test_build.log

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ C:\Data\LaTeX\test-1400\.aux\test-index.log:1: Double-click here to open the ful
8282
# <- meta.summary.success.build.latextools message.info.build.latextools - meta.messages - meta.logfile
8383
#^^^^^^^^^^^^^^^^ meta.summary.success.build.latextools message.info.build.latextools - meta.messages - meta.logfile
8484

85-
[Done!]
85+
[Finished in 3.4s]
8686
# <- meta.summary.success.build.latextools message.info.build.latextools - meta.messages - meta.logfile
87-
#^^^^^^^ meta.summary.success.build.latextools message.info.build.latextools - meta.messages - meta.logfile
87+
#^^^^^^^^^^^^^^^^^ meta.summary.success.build.latextools message.info.build.latextools - meta.messages - meta.logfile
88+
89+
[Finished in 14:25]
90+
# <- meta.summary.success.build.latextools message.info.build.latextools - meta.messages - meta.logfile
91+
#^^^^^^^^^^^^^^^^^^ meta.summary.success.build.latextools message.info.build.latextools - meta.messages - meta.logfile

0 commit comments

Comments
 (0)