Results 1 to 3 of 3

Thread: How do I use Igor Pavlov timer for a Bash script ?

  1. #1
    Member
    Join Date
    Feb 2018
    Location
    indonesia
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How do I use Igor Pavlov timer for a Bash script ?

    I want to measure the time used as I run a Bash script 'd' that'd do compressing and directory listing far better if being automated. So how for me to use Igor Pavlov's timer.exe to obtain the execution-time of that Bash script ?
    Many thanks in advance.

  2. #2
    Programmer schnaader's Avatar
    Join Date
    May 2008
    Location
    Hessen, Germany
    Posts
    616
    Thanks
    264
    Thanked 242 Times in 121 Posts
    "Bash script" sounds like you're going to use Linux, which has a "time" command that can measure the time of a command execution, so I'd prefer this way. If you really want to use timer.exe on a Linux system, you'd have to use wine to execute the Windows binary timer.exe to measure Linux commands, I'm pretty sure this won't work.

    If you meant "batch script" instead (Windows script), just call "timer mybatch.bat" or use "timer" inside of the batch.
    http://schnaader.info
    Damn kids. They're all alike.

  3. #3
    Member
    Join Date
    Dec 2011
    Location
    Cambridge, UK
    Posts
    506
    Thanks
    187
    Thanked 177 Times in 120 Posts
    On linux I prefer to use google perftools as it can give much more information, including important things like clock speed variations.

    Code:
    @ seq3a[/tmp]; perf stat gzip enwik8
    
     Performance counter stats for 'gzip enwik8':
    
           7418.784633 task-clock                #    0.997 CPUs utilized          
                   626 context-switches          #    0.000 M/sec                  
                     0 CPU-migrations            #    0.000 M/sec                  
                   269 page-faults               #    0.000 M/sec                  
           16264693567 cycles                    #    2.192 GHz                     [83.31%]
            8801104276 stalled-cycles-frontend   #   54.11% frontend cycles idle    [83.37%]
            6272475913 stalled-cycles-backend    #   38.56% backend  cycles idle    [66.63%]
           19361014083 instructions              #    1.19  insns per cycle        
                                                 #    0.45  stalled cycles per insn [83.31%]
            3888002759 branches                  #  524.075 M/sec                   [83.41%]
             144395301 branch-misses             #    3.71% of all branches         [83.33%]
    
           7.439664200 seconds time elapsed
    
    @ seq3a[/tmp]; gunzip enwik8.gz
    @ seq3a[/tmp]; perf stat gzip enwik8
    
     Performance counter stats for 'gzip enwik8':
    
           6459.695532 task-clock                #    0.998 CPUs utilized          
                   547 context-switches          #    0.000 M/sec                  
                     0 CPU-migrations            #    0.000 M/sec                  
                   269 page-faults               #    0.000 M/sec                  
           17658879966 cycles                    #    2.734 GHz                     [83.35%]
           10214032205 stalled-cycles-frontend   #   57.84% frontend cycles idle    [83.31%]
            7496824886 stalled-cycles-backend    #   42.45% backend  cycles idle    [66.65%]
           19356436112 instructions              #    1.10  insns per cycle        
                                                 #    0.53  stalled cycles per insn [83.35%]
            3885518453 branches                  #  601.502 M/sec                   [83.37%]
             144184551 branch-misses             #    3.71% of all branches         [83.33%]
    
           6.475480539 seconds time elapsed
    This system has automatic cpu frequency scaling enabled in the bios, which makes timings a complete nightmare. The elapsed and CPU time reported by "time" is highly variable, but we see from perf that the number of instructions is the same. Cycles still differs a bit (8.6% variation between 2 runs), but this is much lower than the CPUs variation (15%). I can run it a few times until I see CPU MHz has stabilised, which gives me more confidence the answer is correct. The next two goes I got:

    Code:
     Performance counter stats for 'gzip enwik8':
    
           5560.004486 task-clock                #    0.998 CPUs utilized          
                   472 context-switches          #    0.000 M/sec                  
                     3 CPU-migrations            #    0.000 M/sec                  
                   269 page-faults               #    0.000 M/sec                  
           16309805185 cycles                    #    2.933 GHz                     [83.33%]
            8850957237 stalled-cycles-frontend   #   54.27% frontend cycles idle    [83.36%]
            6365518735 stalled-cycles-backend    #   39.03% backend  cycles idle    [66.67%]
           19354319475 instructions              #    1.19  insns per cycle        
                                                 #    0.46  stalled cycles per insn [83.33%]
            3887668162 branches                  #  699.220 M/sec                   [83.36%]
             144299232 branch-misses             #    3.71% of all branches         [83.32%]
    
           5.572425708 seconds time elapsed
    
    @ seq3a[/tmp]; perf stat gzip enwik8
    
     Performance counter stats for 'gzip enwik8':
    
           5617.336945 task-clock                #    0.998 CPUs utilized          
                   477 context-switches          #    0.000 M/sec                  
                     2 CPU-migrations            #    0.000 M/sec                  
                   269 page-faults               #    0.000 M/sec                  
           16751214185 cycles                    #    2.982 GHz                     [83.30%]
            9285739462 stalled-cycles-frontend   #   55.43% frontend cycles idle    [83.32%]
            6746852365 stalled-cycles-backend    #   40.28% backend  cycles idle    [66.65%]
           19344892064 instructions              #    1.15  insns per cycle        
                                                 #    0.48  stalled cycles per insn [83.36%]
            3886052970 branches                  #  691.796 M/sec                   [83.39%]
             144311360 branch-misses             #    3.71% of all branches         [83.37%]
    
           5.629982425 seconds time elapsed
    I could do that with straight "time" of course, but it's nice to know *why* the variation is happening.

  4. Thanks (3):

    Gonzalo (11th April 2018),pothos2 (12th April 2018),schnaader (11th April 2018)

Similar Threads

  1. IS script help
    By zhuda in forum The Off-Topic Lounge
    Replies: 3
    Last Post: 10th February 2015, 18:03
  2. Timer 3.01 bug
    By Rugxulo in forum The Off-Topic Lounge
    Replies: 7
    Last Post: 31st July 2009, 21:36
  3. Alternative timer
    By Bulat Ziganshin in forum The Off-Topic Lounge
    Replies: 4
    Last Post: 4th July 2009, 03:16
  4. What's wrong with my testing script?
    By m^2 in forum Data Compression
    Replies: 20
    Last Post: 21st September 2008, 19:24
  5. A high precision timer
    By Matt Mahoney in forum Forum Archive
    Replies: 8
    Last Post: 17th January 2008, 03:36

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •