Changeset 12109
- Timestamp:
- 08/23/09 08:31:19 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abcl/src/org/armedbear/lisp/Time.java
r11714 r12109 40 40 public final class Time extends Lisp 41 41 { 42 private static final long getCurrentThreadUserTime()43 {44 try45 {46 Class c = Class.forName("org.armedbear.lisp.Native");47 Method m = c.getMethod("getCurrentThreadUserTime", (Class[]) null);48 Object result = m.invoke((Object) null, (Object[]) null);49 if (result instanceof Long)50 return ((Long)result).longValue();51 }52 catch (Throwable t) {}53 return -1;54 }55 56 private static final long getCurrentThreadSystemTime()57 {58 try59 {60 Class c = Class.forName("org.armedbear.lisp.Native");61 Method m = c.getMethod("getCurrentThreadSystemTime", (Class[]) null);62 Object result = m.invoke((Object) null, (Object[]) null);63 if (result instanceof Long)64 return ((Long)result).longValue();65 }66 catch (Throwable t) {}67 return -1;68 }69 42 70 43 // ### %time … … 76 49 { 77 50 Cons.setCount(0); 78 long userStart = -1;79 long systemStart = -1;80 try81 {82 userStart = getCurrentThreadUserTime();83 systemStart = getCurrentThreadSystemTime();84 }85 catch (Throwable t) {}86 51 long realStart = System.currentTimeMillis(); 87 52 try … … 92 57 { 93 58 long realElapsed = System.currentTimeMillis() - realStart; 94 final long userStop;95 final long systemStop;96 if (userStart > 0)97 {98 userStop = getCurrentThreadUserTime();99 systemStop = getCurrentThreadSystemTime();100 }101 else102 {103 userStop = -1;104 systemStop = -1;105 }106 59 long count = Cons.getCount(); 107 60 Stream out = … … 112 65 sb.append(" seconds real time"); 113 66 sb.append(System.getProperty("line.separator")); 114 if (userStart > 0)115 {116 sb.append(String.valueOf((float)(userStop - userStart) / 100));117 sb.append(" seconds user run time");118 sb.append(System.getProperty("line.separator"));119 sb.append(String.valueOf((float)(systemStop - systemStart) / 100));120 sb.append(" seconds system run time");121 sb.append(System.getProperty("line.separator"));122 }123 67 sb.append(count); 124 68 sb.append(" cons cell"); … … 150 94 public LispObject execute() throws ConditionThrowable 151 95 { 152 if (Utilities.isPlatformUnix)153 {154 long userTime = -1;155 long systemTime = -1;156 try157 {158 userTime = getCurrentThreadUserTime();159 systemTime = getCurrentThreadSystemTime();160 }161 catch (Throwable t) {}162 if (userTime >= 0 && systemTime >= 0)163 return number((userTime + systemTime) * 10);164 }165 96 return number(System.currentTimeMillis()); 166 97 }
Note: See TracChangeset
for help on using the changeset viewer.