Nicholas -- On Fri, 2002-02-22 at 19:23, Nicholas Clark wrote: > On Fri, Feb 22, 2002 at 09:00:29AM -0500, Gregor N. Purdy wrote: > > > I'm not surprised that find_op() is causing some distress. The "best > > way" is subject to interpretation, of course. TMTOWTDI all over again. > > I chose this way because whenever I started talking about op lookup > > by name, cries went up about "it will be too slow!". So, I wrote the > > absolutely fastest implementation I could think of. It requires only > > a single scan over the op name to determine whether or not its valid, > > and to return its op index in the oplib in question. I don't recall > > the exact numbers, but I was getting a lookups-per-second on a par > > with the ops-per-second from mops.pasm, which I think is excellent > > (and probably faster than it needs to be :). > > Do you have the benchmarking code handy? > [ie I'd like to see if what I'm thinking of comes anywhere near, on a > quantitative test. I might not have tuits immediately, so there's no > real hurry]
Here's a patch of the dumb little benchmarker I hacked in. It screws up the tests because it changes the intepreter's output, but that shouldn't matter for what you are doing. Regards, -- Gregor ____________________________________________________________________ / Inspiration >> Innovation >> Excellence (TM) \ Gregor N. Purdy [EMAIL PROTECTED] Focus Research, Inc. http://www.focusresearch.com/ 8080 Beckett Center Drive #203 513-860-3570 vox West Chester, OH 45069 513-860-3579 fax \____________________________________________________________________/ [[EMAIL PROTECTED]]$ ping osama.taliban.af PING osama.taliban.af (68.69.65.68) from 20.1.9.11 : 56 bytes of data. >From 85.83.77.67: Time to live exceeded
Index: interpreter.c =================================================================== RCS file: /home/perlcvs/parrot/interpreter.c,v retrieving revision 1.69 diff -a -u -r1.69 interpreter.c --- interpreter.c 14 Feb 2002 05:53:58 -0000 1.69 +++ interpreter.c 14 Feb 2002 19:26:05 -0000 @@ -453,6 +453,12 @@ struct Parrot_Interp * make_interpreter(INTVAL flags) { struct Parrot_Interp *interpreter; + int N = 10000000; + int i; + FLOATVAL start; + FLOATVAL stop; + int op_code; + /* Get an empty interpreter from system memory */ interpreter = mem_sys_allocate((UINTVAL)sizeof(struct Parrot_Interp)); /* Set up the memory allocation system */ @@ -535,6 +541,22 @@ interpreter->op_func_table = interpreter->op_lib->op_func_table; interpreter->op_info_table = interpreter->op_lib->op_info_table; + + /* HACK HACK HACK */ + +#if 0 + fprintf(stderr, ">> Doing %d op lookups...\n", N); + start = Parrot_floatval_time(); + for (i = 0; i < N; i++) { + op_code = interpreter->op_lib->op_code("xor_i_ic_ic"); /* 510, at time of +writing */ + } + stop = Parrot_floatval_time(); + fprintf(stderr, ">> [%d] DONE (%f elapsed, %f per sec).\n", op_code, stop - +start, N / (stop - start)); +#endif + + /* HACK HACK HACK */ + + /* Set I/O data to NULL first or else PIO_init will * assume this interpreter is already initialized. */