Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Track performance stats (memory and time?) #22

Open
coilysiren opened this issue Dec 30, 2019 · 2 comments
Open

Track performance stats (memory and time?) #22

coilysiren opened this issue Dec 30, 2019 · 2 comments

Comments

@coilysiren
Copy link
Owner

No description provided.

@coilysiren
Copy link
Owner Author

I might be able to use docker runtime options to do meaningful comparisons across languages??? https://docs.docker.com/config/containers/resource_constraints/

@luser
Copy link

luser commented Feb 24, 2020

Just thought I'd drop a few links that you might find useful here! You can get the count of CPU instructions executed using perf stat on Linux: http://brendangregg.com/perf.html#CPUstatistics

$ perf stat ./hello
Hello world

 Performance counter stats for './hello':

              0.56 msec task-clock                #    0.632 CPUs utilized          
                 0      context-switches          #    0.000 K/sec                  
                 0      cpu-migrations            #    0.000 K/sec                  
                55      page-faults               #    0.099 M/sec                  
         1,081,405      cycles                    #    1.948 GHz                    
           727,622      stalled-cycles-frontend   #   67.28% frontend cycles idle   
           716,960      instructions              #    0.66  insn per cycle         
                                                  #    1.01  stalled cycles per insn
           148,252      branches                  #  267.062 M/sec                  
             7,975      branch-misses             #    5.38% of all branches        

       0.000878743 seconds time elapsed

       0.000930000 seconds user
       0.000000000 seconds sys

Measuring performance with time is complicated, using instructions is a more stable measure. perf stat has some useful options like -x SEP to generate CSV output and -o <file> to write the output to a file. Note that you might have to tweak some kernel options or run as root to make perf work, but it's pretty good about telling you what you need to do.

If you use the time command (not the shell builtin) you can get peak RSS (which is probably the thing you care about measuring for memory usage) in kilobytes:

$ /usr/bin/time -f '%M' ./hello
Hello world
1340

You can pass -o <file> to ask time to write its output to a file instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants