cvsuser     03/11/13 02:42:38

  Modified:    src      embed.c hash.c
  Log:
  calibrate profile times; dont panic in hash_delete
  
  Revision  Changes    Path
  1.95      +42 -15    parrot/src/embed.c
  
  Index: embed.c
  ===================================================================
  RCS file: /cvs/public/parrot/src/embed.c,v
  retrieving revision 1.94
  retrieving revision 1.95
  diff -u -w -r1.94 -r1.95
  --- embed.c   12 Nov 2003 11:02:33 -0000      1.94
  +++ embed.c   13 Nov 2003 10:42:38 -0000      1.95
  @@ -1,7 +1,7 @@
   /* embed.c
    *  Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
    *  CVS Info
  - *     $Id: embed.c,v 1.94 2003/11/12 11:02:33 leo Exp $
  + *     $Id: embed.c,v 1.95 2003/11/13 10:42:38 leo Exp $
    *  Overview:
    *     The Parrot embedding interface.
    *  Data Structure and Algorithms:
  @@ -349,6 +349,27 @@
       return interpreter->op_info_table[k - PARROT_PROF_EXTRA].full_name;
   }
   
  +/*
  + * with this calibration reported times of parrot -p
  + * match almost these measured with time parrot -b
  + */
  +
  +static FLOATVAL
  +calibrate(Parrot_Interp interpreter)
  +{
  +    int i;
  +    FLOATVAL start, empty;
  +    opcode_t code[] = {1};      /* noop */
  +    opcode_t *pc;
  +
  +    for (empty = 0.0, i = 0; i < 1000000; ++i) {
  +       start = Parrot_floatval_time();
  +       pc =  (interpreter->op_func_table[*code])(code,interpreter);
  +       empty += Parrot_floatval_time() - start;
  +    }
  +    return empty;
  +}
  +
   static void
   print_profile(int status, void *p)
   {
  @@ -360,43 +381,49 @@
           UINTVAL op_count = 0;
           UINTVAL call_count = 0;
           FLOATVAL sum_time = 0.0;
  +        RunProfile *profile = interpreter->profile;
  +        FLOATVAL empty = calibrate(interpreter);
   
  -        PIO_printf(interpreter, "\n\n");
  +        PIO_printf(interpreter, "\n");
           PIO_printf(interpreter, "                   OPERATION PROFILE               
  \n\n");
  -        PIO_printf(interpreter, "  CODE   OP FULL NAME            CALLS  TOTAL TIME 
   AVG TIME\n");
  -        PIO_printf(interpreter, "  -----  -----------------     -------  ---------- 
 ----------\n");
  +        PIO_printf(interpreter, " CODE  OP FULL NAME            CALLS  TOTAL TIME   
AVG T. ms\n");
  +        PIO_printf(interpreter, " ----  -----------------     -------  ----------  
----------\n");
   
  -        for (j = 0; j < interpreter->op_count + PARROT_PROF_EXTRA; j++)
  -            interpreter->profile->data[j].op = j;
  -        qsort(interpreter->profile->data, interpreter->op_count +
  +        for (j = 0; j < interpreter->op_count + PARROT_PROF_EXTRA; j++) {
  +            UINTVAL n = profile->data[j].numcalls;
  +            profile->data[j].op = j;
  +            if (j >= PARROT_PROF_EXTRA)
  +                profile->data[j].time -= (empty * n / 1000000);
  +        }
  +        qsort(profile->data, interpreter->op_count +
                   PARROT_PROF_EXTRA,
                   sizeof(ProfData), prof_sort_f);
           for (j = 0; j < interpreter->op_count + PARROT_PROF_EXTRA; j++) {
  -            UINTVAL n = interpreter->profile->data[j].numcalls;
  -            FLOATVAL t = interpreter->profile->data[j].time;
  +            UINTVAL n = profile->data[j].numcalls;
  +            FLOATVAL t = profile->data[j].time;
               if (n > 0) {
                   op_count++;
                   call_count += n;
                   sum_time += t;
   
  -                k = interpreter->profile->data[j].op;
  -                PIO_printf(interpreter, "  %5d  %-20s  %7vu  %10vf  %10vf\n",
  +                k = profile->data[j].op;
  +                PIO_printf(interpreter, " %4d  %-20s  %7vu  %10vf  %10.4vf\n",
                           k - PARROT_PROF_EXTRA,
                           op_name(interpreter, k),
                           n,
                           t,
  -                        (FLOATVAL)(t / n)
  +                        (FLOATVAL)(t * 1000.0 / n)
                           );
               }
           }
   
  -        PIO_printf(interpreter, "  -----  -----------------     -------  ---------- 
 ----------\n");
  -        PIO_printf(interpreter, "  %5vu  %-20s  %7vu  %10vf  %10vf\n",
  +        PIO_printf(interpreter, " ----  -----------------     -------  ----------  
----------\n");
  +        PIO_printf(interpreter, " %4vu  %-20s  %7vu  %10vf  %10.4vf\n",
                   op_count,
                   "",
                   call_count,
                   sum_time,
  -                (FLOATVAL)(sum_time / (FLOATVAL)call_count)
  +                (FLOATVAL)(sum_time * 1000.0 / (FLOATVAL)call_count)
                   );
       }
   }
  
  
  
  1.55      +2 -18     parrot/src/hash.c
  
  Index: hash.c
  ===================================================================
  RCS file: /cvs/public/parrot/src/hash.c,v
  retrieving revision 1.54
  retrieving revision 1.55
  diff -u -w -r1.54 -r1.55
  --- hash.c    12 Nov 2003 16:45:06 -0000      1.54
  +++ hash.c    13 Nov 2003 10:42:38 -0000      1.55
  @@ -1,7 +1,7 @@
   /* hash.c
    *  Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
    *  CVS Info
  - *     $Id: hash.c,v 1.54 2003/11/12 16:45:06 leo Exp $
  + *     $Id: hash.c,v 1.55 2003/11/13 10:42:38 leo Exp $
    *  Overview:
    *  Data Structure and Algorithms:
    *     A hashtable contains an array of bucket indexes. Buckets
  @@ -329,19 +329,6 @@
   {
       BucketIndex bucket_index;
   
  -#if 0
  -    /* key is verified in the vtable, value is an auto variable */
  -    if (key == NULL) {
  -        internal_exception(INTERNAL_PANIC, "NULL key\n");
  -        return NULLBucketIndex;
  -    }
  -
  -    if (value == NULL) {
  -        internal_exception(INTERNAL_PANIC, "NULL value\n");
  -        return NULLBucketIndex;
  -    }
  -#endif
  -
       bucket_index = hash->free_list;
       if (bucket_index != NULLBucketIndex) {
           HashBucket *bucket = getBucket(hash, bucket_index);
  @@ -362,8 +349,7 @@
   {
       BucketIndex next;
   
  -    if (head != NULLBucketIndex && key == NULL)
  -        PANIC("find_bucket given a null key");
  +    assert(head == NULLBucketIndex || key);
   
       while (head != NULLBucketIndex) {
           HashBucket *bucket = getBucket(hash, head);
  @@ -581,8 +567,6 @@
           }
           prev = bucket;
       }
  -
  -    PANIC("hash_delete given nonexistent key");
   }
   
   Hash *
  
  
  

Reply via email to