/mobile Handheld Friendly website
x64 Ubuntu : Intel® Q6600® quad-core |
Each table row shows performance measurements for this C gcc program with a particular command-line input value N.
| N | CPU secs | Elapsed secs | Memory KB | Code B | ≈ CPU Load |
|---|---|---|---|---|---|
| 500,000 | 3.02 | 2.21 | 4,620 | 487 | 55% 1% 1% 57% |
| 5,000,000 | 29.80 | 22.05 | 4,620 | 487 | 46% 8% 8% 46% |
| 50,000,000 | 298.26 | 222.99 | 4,620 | 487 | 42% 10% 10% 42% |
Read the ↓ make, command line, and program output logs to see how this program was run.
Read thread-ring benchmark to see what this program should do.
gcc (Ubuntu/Linaro 4.7.3-1ubuntu1) 4.7.3
/* The Computer Language Benchmarks Game * http://benchmarksgame.alioth.debian.org/ * contributed by Premysl Hruby */ #include <stdio.h> #include <stdlib.h> #include <pthread.h> #include <string.h> #include <limits.h> #define THREADS (503) struct stack { char x[PTHREAD_STACK_MIN]; }; /* staticaly initialize mutex[0] mutex */ static pthread_mutex_t mutex[THREADS]; static int data[THREADS]; static struct stack stacks[THREADS]; /* stacks must be defined staticaly, or my i386 box run of virtual memory for this * process while creating thread +- #400 */ static void* thread(void *num) { int l = (int)num; int r = (l+1) % THREADS; int token; while(1) { pthread_mutex_lock(mutex + l); token = data[l]; if (token) { data[r] = token - 1; pthread_mutex_unlock(mutex + r); } else { printf("%i\n", l+1); exit(0); } } } int main(int argc, char **argv) { int i; pthread_t cthread; pthread_attr_t stack_attr; if (argc != 2) exit(255); data[0] = atoi(argv[1]); pthread_attr_init(&stack_attr); for (i = 0; i < THREADS; i++) { pthread_mutex_init(mutex + i, NULL); pthread_mutex_lock(mutex + i); pthread_attr_setstack(&stack_attr, &stacks[i], sizeof(struct stack)); pthread_create(&cthread, &stack_attr, thread, (void*)i); } pthread_mutex_unlock(mutex + 0); pthread_join(cthread, NULL); }
Sun, 28 Apr 2013 01:39:51 GMT MAKE: /usr/bin/gcc -pipe -Wall -O3 -fomit-frame-pointer -march=native -pthread threadring.c -o threadring.gcc_run threadring.c: In function ‘thread’: threadring.c:30:12: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] threadring.c: In function ‘main’: threadring.c:67:53: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] threadring.c:72:1: warning: control reaches end of non-void function [-Wreturn-type] rm threadring.c 0.10s to complete and log all make actions COMMAND LINE: ./threadring.gcc_run 50000000 PROGRAM OUTPUT: 292