Executable size and performance vs. C?

Rust 1.8 nightly, Clang 3.7.1, Intel core i5:

C:

 Performance counter stats for './c' (10 runs):

        157.773517      task-clock (msec)         #    0.983 CPUs utilized          
                18      context-switches          #    0.113 K/sec                  
                 0      cpu-migrations            #    0.000 K/sec                  
                44      page-faults               #    0.275 K/sec                  
       460,557,670      cycles                    #    2.879 GHz                      (83.14%)
       299,530,716      stalled-cycles-frontend   #   64.80% frontend cycles idle     (83.14%)
        68,134,185      stalled-cycles-backend    #   14.74% backend  cycles idle     (66.32%)
       348,827,544      instructions              #    0.75  insns per cycle        
                                                  #    0.86  stalled cycles per insn  (83.45%)
         3,424,487      branches                  #   21.404 M/sec                    (83.79%)
            53,505      branch-misses             #    1.61% of all branches          (83.66%)

       0.160472723 seconds time elapsed                                          ( +-  0.40% )

Rust:

 Performance counter stats for 'target/release/rust' (10 runs):

        161.201039      task-clock (msec)         #    0.975 CPUs utilized          
                18      context-switches          #    0.109 K/sec                  
                 0      cpu-migrations            #    0.000 K/sec                  
                81      page-faults               #    0.492 K/sec                  
       469,508,148      cycles                    #    2.850 GHz                      (82.89%)
       254,773,475      stalled-cycles-frontend   #   53.88% frontend cycles idle     (83.28%)
        78,178,590      stalled-cycles-backend    #   16.53% backend  cycles idle     (67.17%)
       455,225,406      instructions              #    0.96  insns per cycle        
                                                  #    0.57  stalled cycles per insn  (83.63%)
       123,972,610      branches                  #  752.610 M/sec                    (83.63%)
           245,925      branch-misses             #    0.20% of all branches          (83.12%)

       0.165250902 seconds time elapsed                                          ( +-  0.62% )

The runtime is within 5 milliseconds. What I find Interesting is the number of branches in C vs Rust...

6 Likes