Branch: Tag:

2003-01-13

2003-01-13 02:07:04 by Martin Stjernholm <mast@lysator.liu.se>

Added a function get_cpu_time that provides an interface for high resolution
cpu time measurement. The clumsier internal_rusage is obsoleted by this.
Also some minor fixes in get_pike_rusage.

Rev: src/builtin_functions.c:1.460
Rev: src/gc.c:1.196
Rev: src/pike_rusage.h:1.11
Rev: src/rusage.c:1.25

2:   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: builtin_functions.c,v 1.459 2003/01/12 16:00:14 mast Exp $ + || $Id: builtin_functions.c,v 1.460 2003/01/13 02:07:04 mast Exp $   */      #include "global.h" - RCSID("$Id: builtin_functions.c,v 1.459 2003/01/12 16:00:14 mast Exp $"); + RCSID("$Id: builtin_functions.c,v 1.460 2003/01/13 02:07:04 mast Exp $");   #include "interpret.h"   #include "svalue.h"   #include "pike_macros.h"
1752:      /*! @decl array(int) rusage()    *! -  *! Return resource usage. +  *! Return resource usage. An error is thrown if it isn't supported +  *! or if the system fails to return any information.    *!    *! @returns    *! Returns an array of ints describing how much resources the interpreter
1784:    *! @elem int major_page_faults    *! Major page faults, i.e. paging with disk I/O required.    *! @elem int swaps -  *! Number of times the process was swapped out entirely. +  *! Number of times the process has been swapped out entirely.    *! @elem int block_input_op    *! Number of block input operations.    *! @elem int block_output_op
1841:    */   void f_rusage(INT32 args)   { -  INT32 *rus,e; +  pike_rusage_t rus; +  size_t e;    struct array *v; -  +     pop_n_elems(args); -  rus=low_rusage(); -  if(!rus) -  PIKE_ERROR("rusage", "System rusage information not available.\n", Pike_sp, args); -  v=allocate_array_no_init(29,0); +  if(!pike_get_rusage (rus)) +  PIKE_ERROR("rusage", "System usage information not available.\n", Pike_sp, args); +  v=allocate_array_no_init(NELEM(rus),0);    -  for(e=0;e<29;e++) +  for(e=0;e<NELEM(rus);e++)    {    ITEM(v)[e].type=T_INT;    ITEM(v)[e].subtype=NUMBER_NUMBER;
2075:    *! of this function varies from system to system.    *!    *! @seealso -  *! @[ctime()], @[localtime()], @[mktime()], @[gmtime()] +  *! @[ctime()], @[localtime()], @[mktime()], @[gmtime()], +  *! @[System.gettimeofday]    */   PMOD_EXPORT void f_time(INT32 args)   {