Help capturing timeit output

Posted on 2007-10-12
Last Modified: 2008-01-09
Hello -

I have the following batch command

timeit copy C:\pic.jpg z:\ /y

using basic > output.log, etc.. I am not able to capture the data output of timeit (provides timing info for my copy command) - any ideas?

Question by:newtontech4
    LVL 9

    Expert Comment

    when you type :timeit copy C:\pic.jpg z:\ /y on the command line, what did you see? what happens?
    LVL 82

    Expert Comment

    TimeIt.exe writes, for whatever reason (probably so as not to interfere with the output of the command it's running) to stderr.
    You can capture the output in a log file by redirecting stderr to the log file:

    timeit whatever.exe 2>ouput.log

    Author Comment

    hi ghostdog74
    Here is the output of the command -  notice since timeit is a windows resource utility I run it and my batch from it's home directory...

    C:\Program Files\Windows Resource Kits\Tools>timeit copy.bat

    C:\Program Files\Windows Resource Kits\Tools>copy C:\pic.jpg z:\ /y
            1 file(s) copied.

    Version Number:   Windows NT 5.1 (Build 2600)
    Exit Time:        9:22 am, Friday, October 12 2007
    Elapsed Time:     0:00:00.390
    Process Time:     0:00:00.031
    System Calls:     4294
    Context Switches: 2454
    Page Faults:      788
    Bytes Read:       1752298
    Bytes Written:    775200
    Bytes Other:      108340

    Author Comment

    Hi oBdA -

    Thanks for your feedback.  I am hoping you can elaborate a little more.

    I noticed that the timeit sends output to it's own dat file - which for the life of me I have no idea how to read.

    LVL 9

    Expert Comment

    TIMEIT's .DAT file is binary encoded but it's really not necessary for us to read it in order to do as you require, try this command in your batch file -

    for /f "tokens=3-5 delims=. " %%t in ('timeit 2^>^&1 copy C:\pic.jpg z:\ /y ^| find /i "Elapsed"') do set timeTAKEN=%%t.%%u

    oBdA was correct in that TIMEIT writes to stderr.  The notion of text handling at the command prompt is divided into 3 possible data streams known as stdout, stderr and stdin (standard out, standard error and standard in).  Non-error related messages should, according to convention, be written by the application to stdout while errors should be written to stderr.  Input is accepted from stdin.  stdout can be redirected using the following syntax -

    dir 1> MYoutput.txt (or abbreviated to dir >MYoutput.txt)

    ... while errors can be redirected using -

    cd THISdoesNOTexist 2> hereISmyERROR.log

    The '1' and '2' prefixing the '>' symbol allow us to designate stdout or stderr redirection respectively.  To redirect stdin, i.e. accept input from somewhere other than the keyboard, use a '<' symbol typically followed by a filename containing the text we'd like entered as automated input.

    The special syntax '2>&1' tells the command shell to send stderr through the same output stream as stdout allowing a script to capture both the stdout and stderr output steams in one pipeline.

    The '^' symbol you see me using in the example I provided prevents the command prompt from applying the redirection or piping components too early in the execution of the statement.

    Author Comment

    Thanks to all for your contributions on this.

    I have decided to run with robocopy - the following works like a charm.
    robocopy "C:\1" "C:\2" /MIR /COPYALL /V /NC /NDL /NP /NFL /LOG:"C:\MYLOGFILE.log" /R:10 /W:30 /ETA

    LVL 1

    Accepted Solution

    PAQed with points refunded (500)

    EE Admin

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
    This article will show, step by step, how to integrate R code into a R Sweave document
    An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

    731 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now