From Fedora Project Wiki

To have equivalent test enviroment - you can use:

  echo 3 > /proc/sys/vm/drop_caches

will drop all disk caches

  cgroups 

can set the size of memory


C OPTIMIZATIONS

gzip

compiled with different compilation flags:

lines with "-" in cells have the same value for all rows

with -O2 -march=i386 -mtune=i686 with -O1 -march=i386 -mtune=i686 with -O0 -march=i386 -mtune=i686 with -march=i386 -mtune=i686 without anything
Number of syscalls - - 5987 - -
Kernel/Userspace ticks 314/7394 (7708) 327/7601 (7928) 361/11299 (11660) 420/11605 (12025) 374/10972 (11346)
Read/Written bytes - - 152595016 - -
Pooling syscalls 0 1 0 0 0

tar:

shows too big changes so not good for any statistic :( (no complicated algorithm there)

octave:

startup of octave package:

with -O2 with -O1 with -O0 without anything
Number of syscalls 13589 ? ? 13594
Kernel/Userspace ticks 585/210 (795) ? ? 694/481 (1175)

t = 0:0.1:6.3; plot (t, cos(t), "-;cos(t);", t, sin(t), "+3;sin(t);"):

with -O2 with -O1 with -O0 without anything
Number of syscalls 13765 ? ? 13755
Kernel/Userspace ticks 610/424 (1034) ? ? 587/844 (1431)

coreutils:

RESTRICTION TO THE MEMORY SIZE

I use to run one process on comp with enough memory and with limited ammount of memory: (the limit was set only for this process - cgroups)

without limit limit 3Mb
Number of syscalls 40348 40367
Kernel/Userspace ticks 1143/3001 (4144) 5437/4168 (9605)
Read/Written bytes 5972809 5973681
Pooling syscalls 0 0


READ BY getc, gets with different buffer size

Playing with cat command:

version 1:

   while ( (c=getc(f)) != EOF) {
      putchar(c);
   }


version2:

   while ( (c=getc(f)) != EOF) {
       if (poc < 99) {
           str[poc]=(char )c;
           poc++;
       } else {
           printf("%s",str);
           poc = 0;
       }
       putchar(c);
   }


version3:

  #define MAX 100
  while ( (fgets(str,MAX, f)) != NULL) {
      puts(str);
  }


version4:

  #define MAX 1000
  while ( (fgets(str,MAX, f)) != NULL) {
      puts(str);
  }


Monitored execname: cat cat1 cat2 cat3 cat4 busybox- static busybox
Number of syscalls: 51 2474 4410 5382 4865 109 142
Kernel/Userspace ticks: 8/0 38/13 59/13 61/5 50/7 13/0 7/0
Read/Written bytes: 204485 204485 204485 204485 204485 203749 204997
Pooling syscalls: 0 0 0 0 0 0 0