Skip to content

Commit 18b6187

Browse files
committed
Print total tangling time
1 parent 05c6eff commit 18b6187

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/ntangle.nim

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# NTangle - Basic tangling of Org documents
22
# https://github.com/OrgTangle/ntangle
33

4-
import os, strformat, strutils, tables, terminal, sequtils
4+
import os, strformat, strutils, tables, terminal, sequtils, times
55

66
type
77
DebugVerbosity = enum dvNone, dvLow, dvHigh
@@ -69,6 +69,7 @@ var
6969
bufEnabled: bool
7070
firstLineSrcBlock = false
7171
blockIndent = 0
72+
startTime: float
7273

7374
proc resetStateVars() =
7475
## Reset all the state variables.
@@ -494,6 +495,9 @@ proc writeFiles() =
494495
# permissions (as Org does too).
495496
file.inclFilePermissions({fpUserExec})
496497

498+
echo ""
499+
styledEcho("Total tangling time: ", fgGreen, fmt"{(cpuTime() - startTime):.2f}", fgDefault, " seconds")
500+
497501
proc doOrgTangle(file: string) =
498502
## Tangle Org file ``file``.
499503
if file.toLowerAscii.endsWith(".org"): # Ignore files with names not ending in ".org"
@@ -510,6 +514,7 @@ proc doOrgTangle(file: string) =
510514

511515
proc ntangle(orgFilesOrDirs: seq[string]) =
512516
## Main
517+
startTime = cpuTime()
513518
try:
514519
for f1 in orgFilesOrDirs:
515520
let

0 commit comments

Comments
 (0)