wasCSharpSQLite – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | /* |
2 | * TimeCmd.java |
||
3 | * |
||
4 | * Copyright (c) 1997 Cornell University. |
||
5 | * Copyright (c) 1997 Sun Microsystems, Inc. |
||
6 | * |
||
7 | * See the file "license.terms" for information on usage and |
||
8 | * redistribution of this file, and for a DISCLAIMER OF ALL |
||
9 | * WARRANTIES. |
||
10 | * |
||
11 | * Included in SQLite3 port to C# for use in testharness only; 2008 Noah B Hart |
||
12 | * |
||
13 | * RCS @(#) $Id: TimeCmd.java,v 1.1.1.1 1998/10/14 21:09:18 cvsadmin Exp $ |
||
14 | * |
||
15 | */ |
||
16 | using System; |
||
17 | namespace tcl.lang |
||
18 | { |
||
19 | |||
20 | /// <summary> This class implements the built-in "time" command in Tcl.</summary> |
||
21 | |||
22 | class TimeCmd : Command |
||
23 | { |
||
24 | /// <summary> See Tcl user documentation for details.</summary> |
||
25 | |||
26 | public TCL.CompletionCode cmdProc( Interp interp, TclObject[] argv ) |
||
27 | { |
||
28 | if ( ( argv.Length < 2 ) || ( argv.Length > 3 ) ) |
||
29 | { |
||
30 | throw new TclNumArgsException( interp, 1, argv, "script ?count?" ); |
||
31 | } |
||
32 | |||
33 | int count; |
||
34 | if ( argv.Length == 2 ) |
||
35 | { |
||
36 | count = 1; |
||
37 | } |
||
38 | else |
||
39 | { |
||
40 | count = TclInteger.get( interp, argv[2] ); |
||
41 | } |
||
42 | |||
43 | long startTime = System.DateTime.Now.Ticks; |
||
44 | for ( int i = 0; i < count; i++ ) |
||
45 | { |
||
46 | interp.eval( argv[1], 0 ); |
||
47 | } |
||
48 | long endTime = System.DateTime.Now.Ticks; |
||
49 | long uSecs = ( ( ( endTime - startTime ) / 10 ) / count ); |
||
50 | if ( uSecs == 1 ) |
||
51 | { |
||
52 | interp.setResult( TclString.newInstance( "1 microsecond per iteration" ) ); |
||
53 | } |
||
54 | else |
||
55 | { |
||
56 | interp.setResult( TclString.newInstance( uSecs + " microseconds per iteration" ) ); |
||
57 | } |
||
58 | return TCL.CompletionCode.RETURN; |
||
59 | } |
||
60 | } |
||
61 | } |