I ran this test on Windows XP (.NET 2003) on a P4 2.8 HT. My results are:
int32: 100% int64: 188% int64_2: 250%
On Sat, Nov 15, 2003 at 12:45:11PM -0800, Tim Hockin wrote:
I think what we need is a benchmark on a typical 32-bit system.
OK, I have whipped up a very rough test to see how much 64 bit math hurts on a 32 bit processor.
This is tested on a K6 running Linux (yes, it's slow).
The tests:
* Each test runs 1000000 loops on a 512 sample buffer with 128 events. * Each test iterates over the buffer, checking if the next event is for the timestamped for the current sample. * If the event is for the current sample, we save the full 64 bit timestamp into an array.
int32: * uses 32 bit offset timestamps * uses a 32 bit iterator (compare and add per sample) * uses a 32 bit compare per sample * uses a 64 bit add and store per event
int64: * uses 64 bit absolute timestamps * uses a 32 bit iterator (compare and add per sample) * uses a 64 bit add and compare per sample * uses a 64 bit store per event
int64_2: * uses 64 bit absolute timestamps * uses a 64 bit iterator (compare and add per sample) * uses a 64 bit compare per sample * uses a 64 bit store per event
The results (user time): ------------ int32: 0m33.690s 100% int64: 0m46.630s 138% int64_2: 0m54.910s 163%
That puts me in the camp of 32 bit offsets.
Code attached.
------------------------------------------------------------------------
#include <stdio.h> #include <stdint.h>
#define N_RUNS 1000000 #define N_SAMPLES 512 #define N_EVENTS 128
void do_int32(void); void do_int64(void); void do_int64_2(void);
int main(void) { #ifdef TEST32 do_int32(); #endif #ifdef TEST64 do_int64(); #endif #ifdef TEST64_2 do_int64_2(); #endif return 0; }
void do_int32(void) { int32_t events[N_EVENTS]; int64_t now = (int64_t)1 << 48; int run; int i;
/* populate the events array, but keep it sorted */ for (i = 0; i < N_EVENTS; i++) { events[i] = N_SAMPLES/N_EVENTS * i; }
/* main test loop */ for (run = 0; run < N_RUNS; run++) { int j = 0; int k = 0; int64_t saved[N_EVENTS];
for (i = 0; i < N_SAMPLES; i++) { /* is there an event due right now? */ while (events[j] == i) { /* save it to incur a conversion */ saved[k] = now + events[j]; j++; k++; } } } }
void do_int64(void) { int64_t events[N_EVENTS]; int64_t now = (int64_t)1 << 48; int run; int i;
/* populate the events array, but keep it sorted */ for (i = 0; i < N_EVENTS; i++) { events[i] = now + (N_SAMPLES/N_EVENTS * i); }
/* main test loop */ for (run = 0; run < N_RUNS; run++) { int j = 0; int k = 0; int64_t saved[N_EVENTS];
for (i = 0; i < N_SAMPLES; i++) { /* is there an event due right now? */ while (events[j] == now+i) { /* save it to incur a conversion */ saved[k] = events[j]; j++; k++; } } } }
void do_int64_2(void) { int64_t events[N_EVENTS]; int64_t now = (int64_t)1 << 48; int run; int i;
/* populate the events array, but keep it sorted */ for (i = 0; i < N_EVENTS; i++) { events[i] = now + (N_SAMPLES/N_EVENTS * i); }
/* main test loop */ for (run = 0; run < N_RUNS; run++) { int64_t i64; int64_t end; int j = 0; int k = 0; int64_t saved[N_EVENTS];
end = now + N_SAMPLES; for (i64 = now; i64 < end; i64++) { /* is there an event due right now? */ while (events[j] == i64) { /* save it to incur a conversion */ saved[k] = events[j]; j++; k++; } } } }
-- Mike Berry Adobe Systems
---------------------------------------------------------------------- Generalized Music Plugin Interface (GMPI) public discussion list Participation in this list is contingent upon your abiding by the following rules: Please stay on topic. You are responsible for your own words. Please respect your fellow subscribers. Please do not redistribute anyone else's words without their permission.
Archive: //www.freelists.org/archives/gmpi Email gmpi-request@xxxxxxxxxxxxx w/ subject "unsubscribe" to unsubscribe