linux-admin.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Miguel González Castaños" <mgc@tid.es>
To: linux-admin@vger.kernel.org
Subject: CPU tests
Date: Fri, 31 Mar 2006 15:08:00 +0200	[thread overview]
Message-ID: <442D29B0.6020806@tid.es> (raw)

[-- Attachment #1: Type: text/plain, Size: 1263 bytes --]

Dear all,

  I am trying to launch CPU tests on a Pentium IV Prescott 3.0 Ghz with 
4Gb of RAM. I have tried some tests from distributed.net and everything 
seems to be ok, although with the test attached in the email (sorry for 
the size of the mail), I am experiencing some problems. As you can see 
with the static flag the number generation is faster than without that 
flag. I have gcc 4.0.2 under Fedora with a compiled kernel 2.6.15.

gcc test-cpu-2.c -o test-cpu-2 -lm -O3
./test-cpu-2
10 millions of rand() en 6.270 seconds (result of i.e.: 1829503671)
10 millions of sqrt(i) en 0.210 seconds (result of i.e..: 3162)
10 millions of random() en 4.260 seconds (result of i.e..: 25948597)
10 millions of log(i) en 12.510 seconds (result of i.e..: 16)

gcc test-cpu-2.c -o test-cpu-2 -lm -O3 -static
./test-cpu-2
10 millions de rand() en 0.220 seconds (result of i.e.: 1396595316)
10 millions de sqrt(i) en 0.210 seconds (result of i.e.: 3162)
10 millions de random() en 0.210 seconds (result of i.e.: 12140342)
10 millions de log(i) en 0.960 seconds (result of i.e.: 16)

Many thanks in advance

Miguel

ps: If you try the C code, you will see that I have translated the 
spanish messages in the email but not in the code, hope it is easy to 
understand :)

[-- Attachment #2: test-cpu2.c --]
[-- Type: text/plain, Size: 1952 bytes --]

#include <stdio.h> 
#include <stdlib.h> 
#include <math.h> 
#include <time.h>
#include <string.h>


int hora(void) {
    time_t t;
    time(&t);
    struct tm* petm = localtime(&t);

    return petm->tm_hour;
}

int minutos(void) {
    time_t t;
    time(&t);
    struct tm* petm = localtime(&t);

    return petm->tm_min;
}

int segundos(void) {
    time_t t;
    time(&t);
    struct tm* petm = localtime(&t);

    return petm->tm_sec;
}

int main(int argc, char ** argv) { 
    time_t seconds;
    int i, r, numero_ciclos, numero_ciclosM, t1, t2;
    clock_t start, end;
    
    // Se inicializa el generador de numeros aleatorios
    time(&seconds);
    srand((unsigned int) seconds);

    numero_ciclos = 10000000; numero_ciclosM = numero_ciclos / 1E6;
    start = clock();
    for(i=0; i<numero_ciclos; i++) {
        r = rand();
    }
    end = clock();
    printf("%d millones de rand() en %.3f segundos (resultado de ej.: %d)\n", numero_ciclosM, (double)(end - 
start)/CLOCKS_PER_SEC, r);


    numero_ciclos = 10000000; numero_ciclosM = numero_ciclos / 1E6;
    start = clock();
    for(i=0; i<numero_ciclos; i++) {
        r = sqrt(i);
    }
    end = clock();
    printf("%d millones de sqrt(i) en %.3f segundos (resultado de ej.: %d)\n", numero_ciclosM, (double)(end - 
start)/CLOCKS_PER_SEC, r);


    numero_ciclos = 10000000; numero_ciclosM = numero_ciclos / 1E6;
    start = clock();
    for(i=0; i<numero_ciclos; i++) {
        r = random();
    }
    end = clock();
    printf("%d millones de random() en %.3f segundos (resultado de ej.: %d)\n", numero_ciclosM, (double)(end - 
start)/CLOCKS_PER_SEC, r);
 numero_ciclos = 10000000; numero_ciclosM = numero_ciclos / 1E6;
    start = clock();
    for(i=0; i<numero_ciclos; i++) {
        r = log(i);
    }
    end = clock();
    printf("%d millones de log(i) en %.3f segundos (resultado de ej.: %d)\n", numero_ciclosM, (double)(end - 
start)/CLOCKS_PER_SEC, r);


    return (0);
} 


             reply	other threads:[~2006-03-31 13:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-31 13:08 Miguel González Castaños [this message]
2006-03-31 14:28 ` CPU tests Tim Walberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=442D29B0.6020806@tid.es \
    --to=mgc@tid.es \
    --cc=linux-admin@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).