Timing commands with $= in the prompt?

May 20, 2008
11,409
99
Syracuse, NY, USA
As far as I can tell, the minimum time that can be measured with $= in the prompt is 50 ms. For example

Code:
v:\> eset prompt
prompt=$= $e[32;1m$p$g$s$e[0m

5.043 v:\> ()

0.050 v:\> noop

0.050

In fact anything measured with $= is 50 ms longer than when measured with TIMER.

I don't know when this started but it is not the case in v20.

Code:
g:\tc20> ver

TCC  20.11.46   Windows 7 [Version 6.1.7601]

g:\tc20> eset prompt
PROMPT=$= $e[32;1m$p$g$s$e[0m

0:00:04.98 g:\tc20> ()

0:00:00.00 g:\tc20> noop

0:00:00.00 g:\tc20>

Can the behavior be changed so that timing with $= will be more accurate?

Speculation: It's almost as if there's a hard-coded Sleep(50) after the start time of a command is recorded (I see the same thing if I use PRE_EXEC and POST_EXEC to do the timing myself). If that's the case, couldn't 50 ms be subtracted from $='s time (and the result max'd with 0)? If that's not the case, I'm very curious about what's happening.
 

rconn

Administrator
Staff member
May 14, 2008
12,352
150
1. There is no Sleep().
2. TCC v20 shows 0 because its timer resolution is much coarser (like 50x).
3. On my system, I see about 0.006 seconds for something like "rem".
4. You apparently believe that executing several thousand lines of code to parse the command line (even if it's only something like "rem") can be done without using any CPU cycles. Would that it were true ...
 
May 20, 2008
11,409
99
Syracuse, NY, USA
1. There is no Sleep().
2. TCC v20 shows 0 because its timer resolution is much coarser (like 50x).
3. On my system, I see about 0.006 seconds for something like "rem".
4. You apparently believe that executing several thousand lines of code to parse the command line (even if it's only something like "rem") can be done without using any CPU cycles. Would that it were true ...
Here, REM shows 0.050.
Code:
v:\> eset prompt
prompt=$= $e[32;1m$p$g$s$e[0m

3.717 v:\> rem

0.050 v:\>

And EVERYTHING takes ~50 ms longer according to $= than according to TIMER.

Code:
0.050 v:\> timer & (rem) & timer
Timer 1 on: 21:45:12
Timer 1 off: 21:45:12  Elapsed: 0:00:00.001

0.052 v:\>

Code:
0.050 v:\> timer & do i=1 to 10000 ( rem ) & timer
Timer 1 on: 21:50:58
Timer 1 off: 21:50:59  Elapsed: 0:00:01.427

1.478 v:\>

I see the same ~50 ms if I do the timing like this:

Code:
v:\> alias pre_exec `timer /10 /q on`

0.000 v:\> set prompt=`%@timer[10]$s$p$g$s`

0:00:00.049 v:\> rem

0:00:00.049 v:\>

50 ms is quite a long time. I know TCC can parse much longer command lines in much less time. And, here, that ~50 ms is pretty constant. Do you have any concrete ideas about what I'm seeing/measuring?
 
May 20, 2008
11,409
99
Syracuse, NY, USA
It's the History logging! Using $= ...

Code:
0.000 v:\> rem

0.050 v:\> option //histlogon=no

0.050 v:\> rem

0.001 v:\>

Can the timer for $= be started after the command is logged? ... maybe PRE_EXEC done after the logging also?
 
May 20, 2008
11,409
99
Syracuse, NY, USA
Not without rewriting the parser (and breaking everything else).
Oh, well! No big deal. TIMER works well.

My history log was about 1MB. Copying it to an archive and emptying it brought the 50 ms for REM down to 4 ms. I think I'll make a task to do that regularly. I don't normally use $= in my prompt, but keeping the log file small will speed everything up even when I'm not timing anything.

I'm a little surprised that seeking to the end of a 1MB file takes that long.
 
May 20, 2008
11,409
99
Syracuse, NY, USA
I guess you could move your log files to a RAMdisk.... :rolleyes:
That's not very permanent. I like having a record of everything I've done. I don't like figuring out difficult command lines (DUMPEL.EXE comes to mind) years after I last used them.

That said ... I used to love ramdisk.sys. Are there any modern ones? ... that automatically backup/restore their contents at shutdown/startup?
 

rconn

Administrator
Staff member
May 14, 2008
12,352
150
Oh, well! No big deal. TIMER works well.

My history log was about 1MB. Copying it to an archive and emptying it brought the 50 ms for REM down to 4 ms. I think I'll make a task to do that regularly. I don't normally use $= in my prompt, but keeping the log file small will speed everything up even when I'm not timing anything.

I'm a little surprised that seeking to the end of a 1MB file takes that long.

History logging uses Windows APIs call to request a semaphore to lock the file, open the file, seek to the end, write the command, close the file & release the semaphore. If you want all of that to run faster, you should contact Microsoft directly. (Or get a faster system!)
 
May 20, 2008
11,409
99
Syracuse, NY, USA
History logging uses Windows APIs call to request a semaphore to lock the file, open the file, seek to the end, write the command, close the file & release the semaphore. If you want all of that to run faster, you should contact Microsoft directly. (Or get a faster system!)
My new computer seems pretty fast ... 3.5MHz, SSDs, 16GB RAM. How much faster do workstations get?
 
... nothing!

Did you create the virtual Disk in virtual or physical memory?
1574278370300.png

Not sure if it will make any difference, though.

Joe
 
May 20, 2008
11,409
99
Syracuse, NY, USA
Did you create the virtual Disk in virtual or physical memory?
View attachment 2593
Not sure if it will make any difference, though.

Joe
It was in virtual memory. So I tried again, putting it in physical memory ... no difference. When I copied my archived 1MB history log to the ramdrive history log, the $= time for REM went right back to 50 ms. I guess the moral of the story is that the SSD is pretty fast and the Win32 APIs that Rex described are the limiting factor.
 
Similar threads
Thread starter Title Forum Replies Date
vefatica Console not redrawn in BTM or with multiple commands Support 4
Joe Caverly Documentation COMMANDS in Version 27 help Support 8
kb6ojs ALIAS with multiple commands? Support 9
R Long commands retrieved from command history have blank line when wrapped Support 20
A Fixed v25 regression: Parameter expansion fails in piped commands Support 2
A Key Commands missing? Support 3
Dick Johnson New database commands Support 8
F Regexes in REN/MOVE/… commands seem to not work at all Support 3
gentzel Bug launching external commands in 20.11.43 Support 11
M Keywords for commands, functions, internal variables Support 3
M Disable commands? Support 2
D Fixed 20.10 strangeness with external commands Support 9
thedave Problem chaining piped FIND commands in BTM Support 7
D Some commands are not displaying their command dialog Support 2
C MONITOR commands alter tab title when triggered Support 0
Alpengreis Documentation TC Help v18.x "Commands by Category" is incomplete Support 0
R How to? Launch and execute commands in tcmd.exe through MSBuild Script. Support 3
D WAD TASKBAR window commands confuses our friends at MS Support 4
Stefano Piccardi list of TCC commands for external editors Support 4
I tab completion with directory commands Support 7
I most used commands Support 2
mikea How to? TCC and ftp:// commands Support 7
R Override TCC internal commands Support 2
S Directory history entries from /S option of various commands Support 2
M A simple question related to the "dir" (and "pdir") commands... Support 5
R TC 13 / Using TCDIALOG to exit commands Support 4
J syntax problems multiple commands (command & command) Support 4
C User error with low level file* commands Support 8
S Need help to execute TCC commands on another system Support 6
electrotype keyboard shotcuts to send commands to a TCC tab? Support 8
Charles Dye Updated _bat.schclass with v11 new commands/keywords Support 1
L Vista 64 bits missing commands Support 1
deleyd Commands to launch Control Panel items? Support 10
vefatica ANSI, PROMPT ... ??? Support 1
FreezerBurnt ANSI Prompt messes up list output. Support 39
FreezerBurnt "Missing SETLOCAL" when initializing Visual Studio Command Prompt. Support 9
M How to? Black TCC Prompt Support 2
N Command execution slows down in TCC Prompt after a while Support 6
K Fixed Prompt display will be shifted after use dir to display a filename with Chinese. (v25.00.28 x64) Support 18
samintz How to? Alias or prompt? Support 1
T Elapsed time format in prompt changed in TCC 25 Support 10
samintz MOVE and Prompt on overwrite Support 3
robinsiebler Creating a custom prompt Support 9
K TCC prompt background color Support 4
Alpengreis Problem if command prompt is not legacy Support 4
Joe Caverly Documentation Customizing the TCC Prompt Support 0
C How to? handle the UAC prompt on computer restarts with Everything Support 3
B when doing SFTP via IFTP to my secure site my users always get the finger print key prompt Support 1
M PROMPT with git branch Support 1
MikeBaas How to? SELECT: exclude files / display prompt Support 2

Similar threads