[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: gEDA-user: pcb crooked traces



timecop:
> Does anyone on this list honestly believe that in 2010 a difference
> between "slow emulated 64bit" and "native 64bit" integer on any
> hardware made in the last decade is going to be even noticeable.
...

You have to test to know, and you can get a first impression by
this simplistic test:

$ cat testb.c
#include <math.h>
#include <stdint.h>
#include <stdio.h>
#include <sys/time.h>

#define TESTIT(op, str) \
  gettimeofday(&sta, NULL); \
  for (ix = 0; ix < 1000000000; ix++) { \
    (op); \
  } \
  gettimeofday(&end, NULL); \
  timersub(&end, &sta, &diff); \
  printf(str " %ld.%06ld\n", diff.tv_sec, diff.tv_usec);

int main(void) {
  struct timeval sta;
  struct timeval end;
  struct timeval diff;
  int32_t xi;
  int64_t xl;
  double  xd;
  int ix;
  double sqrt2 = sqrt(2);

  xd = xl = xi = 0;
  printf("Loop time for x++\n");
  TESTIT(xi++, "int32_t");
  TESTIT(xl++, "int64_t");
  TESTIT(xd++, "double ");

  xd = xl = xi = 1;
  printf("\nLoop time for x *= 5\n");
  TESTIT(xi *= 5, "int32_t");
  TESTIT(xl *= 5, "int64_t");
  TESTIT(xd *= 5, "double ");

  xd = xl = xi = 1;
  printf("\nLoop time for x *= sqrt2\n");
  TESTIT(xi *= sqrt2, "int32_t");
  TESTIT(xl *= sqrt2, "int64_t");
  TESTIT(xd *= sqrt2, "double ");

  return 0;
}
$ gcc -lm testb.c -o testb
$ ./testb
Loop time for x++
int32_t 3.600433
int64_t 4.301995
double  7.725700

Loop time for x *= 5
int32_t 5.205665
int64_t 8.391968
double  7.733138

Loop time for x *= sqrt2
int32_t 22.415493
int64_t 22.022103
double  7.911313
$ grep 'name' /proc/cpuinfo 
model name      : AMD Athlon(TM) XP 2400+
$

   On another box:

$ ./testb 
Loop time for x++
int32_t 2.429795
int64_t 2.664763
double  5.269211

Loop time for x *= 5
int32_t 2.641352
int64_t 4.079825
double  5.107343

Loop time for x *= sqrt2
int32_t 14.814515
int64_t 14.814356
double  4.951645
$ grep 'name' /proc/cpuinfo | head -1
model name      : AMD Phenom(tm) II X4 925 Processor
$

As you can see from above:
 int32_t is fastest for simple + and *
 double  has an almost constant operator time

The performance choise is between int32_t and double:
 for "+" int32_t wins with a factor 2, and for "*" double wins 
 with a factor 3.

What operation is the most common in pcb ?

Regards,
/Karl Hammar

---------
Aspö Data
Lilla Aspö 148
S-742 94 Östhammar
Sweden
+46 173 140 57




_______________________________________________
geda-user mailing list
geda-user@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user