Changeset 8411


Ignore:
Timestamp:
01/30/05 02:35:37 (16 years ago)
Author:
piso
Message:

getCurrentThreadUserTime(), getCurrentThreadSystemTime()

Location:
trunk/j/src/org/armedbear/lisp
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/j/src/org/armedbear/lisp/ControlC.c

    r6657 r8411  
    22 * ControlC.c
    33 *
    4  * Copyright (C) 2004 Peter Graves
    5  * $Id: ControlC.c,v 1.1 2004-04-30 01:45:44 piso Exp $
     4 * Copyright (C) 2004-2005 Peter Graves
     5 * $Id: ControlC.c,v 1.2 2005-01-30 02:34:17 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    2222#include "ControlC.h"
    2323#include <signal.h>
     24#include <sys/times.h>
    2425
    2526JNIEnv *_env;
     
    4243        sleep(31536000);
    4344}
     45
     46JNIEXPORT jlong JNICALL
     47Java_org_armedbear_lisp_ControlC_getCurrentThreadUserTime(JNIEnv *env, jclass cls)
     48{
     49    struct tms buf;
     50    times(&buf);
     51    return buf.tms_utime;
     52}
     53
     54JNIEXPORT jlong JNICALL
     55Java_org_armedbear_lisp_ControlC_getCurrentThreadSystemTime(JNIEnv *env, jclass cls)
     56{
     57    struct tms buf;
     58    times(&buf);
     59    return buf.tms_stime;
     60}
  • trunk/j/src/org/armedbear/lisp/ControlC.java

    r6938 r8411  
    22 * ControlC.java
    33 *
    4  * Copyright (C) 2004 Peter Graves
    5  * $Id: ControlC.java,v 1.4 2004-05-29 15:19:15 piso Exp $
     4 * Copyright (C) 2004-2005 Peter Graves
     5 * $Id: ControlC.java,v 1.5 2005-01-30 02:34:52 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    2626    public static native void installControlCHandler();
    2727
     28    public static native long getCurrentThreadUserTime();
     29    public static native long getCurrentThreadSystemTime();
     30
    2831    public static void callback()
    2932    {
     
    3134    }
    3235
    33     public void run() {
     36    public void run()
     37    {
    3438        installControlCHandler(); // Never returns.
    3539    }
  • trunk/j/src/org/armedbear/lisp/Time.java

    r8334 r8411  
    33 *
    44 * Copyright (C) 2003-2005 Peter Graves
    5  * $Id: Time.java,v 1.24 2005-01-10 17:43:07 piso Exp $
     5 * $Id: Time.java,v 1.25 2005-01-30 02:35:37 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    3434        {
    3535            Cons.setCount(0);
    36             long start = System.currentTimeMillis();
     36            long userStart = -1;
     37            long systemStart = -1;
     38            try {
     39                userStart = ControlC.getCurrentThreadUserTime();
     40                systemStart = ControlC.getCurrentThreadSystemTime();
     41            }
     42            catch (Throwable t) {}
     43            long realStart = System.currentTimeMillis();
    3744            try {
    3845                return arg.execute();
    3946            }
    4047            finally {
    41                 long elapsed = System.currentTimeMillis() - start;
     48                long realElapsed = System.currentTimeMillis() - realStart;
     49                long userStop = -1;
     50                long systemStop = -1;
     51                if (userStart > 0) {
     52                    userStop = ControlC.getCurrentThreadUserTime();
     53                    systemStop = ControlC.getCurrentThreadSystemTime();
     54                }
    4255                long count = Cons.getCount();
    4356                Stream out =
    4457                    checkCharacterOutputStream(_TRACE_OUTPUT_.symbolValue());
    4558                out.freshLine();
    46                 StringBuffer sb =
    47                     new StringBuffer(String.valueOf((float)elapsed/1000));
    48                 sb.append(" seconds");
     59                StringBuffer sb = new StringBuffer();
     60                sb.append(String.valueOf((float)realElapsed/1000));
     61                sb.append(" seconds real time");
    4962                sb.append(System.getProperty("line.separator"));
     63                if (userStart > 0) {
     64                    sb.append(String.valueOf((float)(userStop - userStart)/100));
     65                    sb.append(" seconds user run time");
     66                    sb.append(System.getProperty("line.separator"));
     67                    sb.append(String.valueOf((float)(systemStop - systemStart)/100));
     68                    sb.append(" seconds system run time");
     69                    sb.append(System.getProperty("line.separator"));
     70                }
    5071                if (count > 0) {
    5172                    sb.append(count);
Note: See TracChangeset for help on using the changeset viewer.