Sometimes after performing a batch of windows, you want to know how much time this process takes, and if the C code under Windows can call GetTickCount () before and after the procedure, then subtract to get the time it takes.
But if there is no such ready-made function in batch processing, and I have been looking for a long time on the internet did not find. Finally, after the batch processing variable calculation is taken, and the return value is obtained from EXE, the function is finally realized.
Evaluate in batches
The following code will print out the 20
1 @echo off2 set cho=233 set/a res=%cho%-34 Echo%res%
Note that after the first set = Must not be preceded by a space, the second set must have A/a
Get the return value of EXE
With%errorlevel% you can get the return value after executing an EXE.
/wait Program.exeset r=%errorlevel%%r%
GetTickCount Program
Write a simple C program that calls GetTickCount () to return its value
#include <windows.h><stdio.h>int main (intChar* * argv) { int t = GetTickCount (); printf ("%d\n", T); return t;}
Arbitrarily use a C compiler, the above C source code compiled into EXE program, named GetTickCount.exe, and put it into a system path.
Application
/wait GetTickCount.exeset t1=%errorlevel%3
:: TODO Something
/wait GetTickCount.exeset t2=%errorlevel%set/a t=%t2%-%t1%echo%t%
The time spent in milliseconds is finally printed.
Download path for GetTickCount Http://files.cnblogs.com/files/xiangism/GetTickCount.rar
Bash in Linux for timing
By the way, how to implement timing in a shell under Linux
#!/bin/bashstart=$ (date"+%s") # do something sleep2now =$ (date"+%s") Time =$ (now-start) echo"timeused: $time seconds "
~~~~eureka~~~~
Implementing the Clocking feature under Windows batch processing