On Thu, 23 Oct 2008 18:10:50 +0300, Marc Feeley <feeley@iro.umontreal.ca> wrote:
/* * File: "timer-perf.c". * * This program was written by Marc Feeley (feeley@iro.umontreal.ca). * * This program tests the accuracy of the ITIMER_VIRTUAL and ITIMER_REAL * timers. When the setitimer is used to request a given timer interval * the system will setup the timer to deliver a "heartbeat interrupt" * at a certain interval, which generally is not exactly the one * requested (because the timers have a certain granularity and a * minimal interval). With a call to getitimer it is possible to * determine which interval was set by the OS (the "claimed" interval). * * In this test, "accuracy" is measured as the ratio between the * claimed interval and the actual interval obtained. The tests * on Mac OS X and Linux show that the timer granularity, minimal * interval and accuracy vary considerably between these operating * systems. * * Execution on Mac OS X 10.5.5 on a Mac Book Pro with Intel Core Duo: * * % gcc timer-perf.c * % time ./a.out * ITIMER_REAL: requested, claimed and actual intervals in us and accuracy * 100000 100000 101318 (101%) * 50000 50000 50061 (100%) * 20000 20000 19884 (99%) * 10000 10000 9945 (99%) * 5000 5000 4957 (99%) * 2000 2000 1970 (98%) * 1000 1000 979 (97%) * 500 500 482 (96%) * 200 200 183 (91%) * 100 100 86 (86%) * ITIMER_VIRTUAL: requested, claimed and actual intervals in us and accuracy * 100000 100000 103766 (103%) * 50000 50000 52527 (105%) * 20000 20000 22161 (110%) * 10000 10000 11818 (118%) * 5000 5000 7286 (145%) * 2000 2000 4527 (226%) * 1000 1000 3141 (314%) * 500 500 2762 (552%) * 200 200 2333 (1166%) * 100 100 2407 (2407%) * done (dummy = 1566934064) * * real 1m27.405s * user 1m25.414s * sys 0m1.516s * * Execution on Linux: * * % gcc timer-perf.c * % time ./a.out * ITIMER_REAL: requested, claimed and actual intervals in us and accuracy * 100000 100000 104387 (104%) * 50000 50000 50639 (101%) * 20000 20000 20074 (100%) * 10000 10000 10037 (100%) * 5000 5000 5018 (100%) * 2000 2000 4000 (200%) * 1000 1000 4007 (400%) * 500 500 4007 (801%) * 200 200 3978 (1989%) * 100 100 4000 (4000%) * ITIMER_VIRTUAL: requested, claimed and actual intervals in us and accuracy * 100000 100006 104197 (104%) * 50000 52003 52098 (100%) * 20000 20001 20142 (100%) * 10000 12000 12043 (100%) * 5000 8000 8029 (100%) * 2000 4000 4007 (100%) * done (dummy = 2132937504) * * real 0m35.339s * user 0m35.302s * sys 0m0.000s */
Here are the results for 2 linux systems RHEL 4.7 64 bit, 2 x intel xeon CPU 3.20GHz Two sequential runs in foreground =================================== ITIMER_REAL: requested, claimed and actual intervals in us and accuracy 100000 100984 103615 (102%) 50000 50992 51316 (100%) 20000 20996 21019 (100%) 10000 10998 11027 (100%) 5000 5999 5819 (97%) 2000 2999 3002 (100%) 1000 1999 2000 (100%) 500 999 1000 (100%) ITIMER_VIRTUAL: requested, claimed and actual intervals in us and accuracy 100000 100984 102089 (101%) 50000 50992 52343 (102%) 20000 20996 21194 (100%) 10000 10998 11052 (100%) 5000 5999 6004 (100%) 2000 2999 3002 (100%) 1000 1999 2000 (100%) 500 999 1000 (100%) done (dummy = 1551135873) real 0m32.383s user 0m32.311s sys 0m0.065s ITIMER_REAL: requested, claimed and actual intervals in us and accuracy 100000 100984 102194 (101%) 50000 50992 51702 (101%) 20000 20996 21064 (100%) 10000 10998 11003 (100%) 5000 5999 6011 (100%) 2000 2999 3001 (100%) 1000 1999 2000 (100%) 500 999 1000 (100%) ITIMER_VIRTUAL: requested, claimed and actual intervals in us and accuracy 100000 100984 101603 (100%) 50000 50992 51387 (100%) 20000 20996 21189 (100%) 10000 10998 11004 (100%) 5000 5999 6005 (100%) 2000 2999 3003 (100%) 1000 1999 2001 (100%) 500 999 1000 (100%) done (dummy = 1525906181) real 0m31.960s user 0m31.953s sys 0m0.002s Four parallel runs in background ================================== ITIMER_REAL: requested, claimed and actual intervals in us and accuracy 100000 100984 103826 (102%) 50000 50992 51044 (100%) 20000 20996 21208 (101%) 10000 10998 11023 (100%) 5000 5999 6002 (100%) 2000 2999 3001 (100%) 1000 1999 1999 (100%) 500 999 999 (100%) ITIMER_VIRTUAL: requested, claimed and actual intervals in us and accuracy 100000 100984 102616 (101%) 50000 50992 51911 (101%) 20000 20996 21211 (101%) 10000 10998 11050 (100%) 5000 5999 6007 (100%) 2000 2999 3002 (100%) 1000 1999 2000 (100%) 500 999 1000 (100%) done (dummy = 214280170) 9 parallel runs in background ================================== ITIMER_REAL: requested, claimed and actual intervals in us and accuracy 100000 100984 52943 (52%) 50000 50992 33174 (65%) 20000 20996 17676 (84%) 10000 10998 10034 (91%) 5000 5999 5727 (95%) 2000 2999 2998 (99%) 1000 1999 2000 (100%) 500 999 999 (100%) ITIMER_VIRTUAL: requested, claimed and actual intervals in us and accuracy 100000 100984 101439 (100%) 50000 50992 51376 (100%) 20000 20996 21085 (100%) 10000 10998 11014 (100%) 5000 5999 6017 (100%) 2000 2999 3004 (100%) 1000 1999 2000 (100%) 500 999 1000 (100%) done (dummy = 680961885) --------------------------------------------- RHEL 4.7 32 bit pentium4 2.4 GHz Two sequential runs in foreground =================================== ITIMER_REAL: requested, claimed and actual intervals in us and accuracy 100000 100984 103219 (102%) 50000 50992 50919 (99%) 20000 20996 21068 (100%) 10000 10998 10988 (99%) 5000 5999 5988 (99%) 2000 2999 2995 (99%) 1000 1999 1995 (99%) 500 999 999 (100%) ITIMER_VIRTUAL: requested, claimed and actual intervals in us and accuracy 100000 100984 103131 (102%) 50000 50992 51624 (101%) 20000 20996 21038 (100%) 10000 10998 11017 (100%) 5000 5999 6000 (100%) 2000 2999 3001 (100%) 1000 1999 2000 (100%) 500 999 1000 (100%) done (dummy = 825648992) real 0m56.543s user 0m56.344s sys 0m0.023s ITIMER_REAL: requested, claimed and actual intervals in us and accuracy 100000 100984 103287 (102%) 50000 50992 51529 (101%) 20000 20996 21038 (100%) 10000 10998 10995 (99%) 5000 5999 5993 (99%) 2000 2999 2996 (99%) 1000 1999 1995 (99%) 500 999 999 (100%) ITIMER_VIRTUAL: requested, claimed and actual intervals in us and accuracy 100000 100984 103337 (102%) 50000 50992 51653 (101%) 20000 20996 21032 (100%) 10000 10998 11020 (100%) 5000 5999 6004 (100%) 2000 2999 3001 (100%) 1000 1999 2000 (100%) 500 999 1000 (100%) done (dummy = 952733829) real 0m56.356s user 0m56.164s sys 0m0.019s Four concurrent runs in background =================================== ITIMER_REAL: requested, claimed and actual intervals in us and accuracy 100000 100984 50292 (49%) 50000 50992 34130 (66%) 20000 20996 17724 (84%) 10000 10998 10007 (90%) 5000 5999 5735 (95%) 2000 2999 2936 (97%) 1000 1999 1966 (98%) 500 999 999 (100%) ITIMER_VIRTUAL: requested, claimed and actual intervals in us and accuracy 100000 100984 103102 (102%) 50000 50992 51712 (101%) 20000 20996 21038 (100%) 10000 10998 11023 (100%) 5000 5999 6009 (100%) 2000 2999 3001 (100%) 1000 1999 2000 (100%) 500 999 1000 (100%) done (dummy = -364232017) ________ Information from NOD32 ________ This message was checked by NOD32 Antivirus System for Linux Mail Servers. part000.txt - is OK test6.ok - is OK test4.ok - is OK http://www.eset.com