[m-rev.] diff: Implement c_times in C#

Peter Ross pro at missioncriticalit.com
Wed Jul 18 18:12:54 AEST 2012


Hi,


===================================================================


Estimated hours taken: 1
Branches: main, 11.07

library/time.m:
	Implement c_times in C#.


Index: library/time.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/time.m,v
retrieving revision 1.72
diff -u -r1.72 time.m
--- library/time.m	26 Oct 2011 14:08:44 -0000	1.72
+++ library/time.m	18 Jul 2012 07:46:17 -0000
@@ -415,6 +415,26 @@
     CSt = 0;
 ").
 
+:- pragma foreign_proc("C#",
+    c_times(Ret::out, Ut::out, St::out, CUt::out, CSt::out,
+        _IO0::di, _IO::uo),
+    [will_not_call_mercury, promise_pure, tabled_for_io, may_not_duplicate],
+"
+    Ret = (int) System.DateTime.UtcNow.Ticks;
+
+    // Ret = Ret & 0x7fffffff;
+
+    long user = System.Diagnostics.Process.GetCurrentProcess().UserProcessorTime.Ticks;
+    long total = System.Diagnostics.Process.GetCurrentProcess().TotalProcessorTime.Ticks;
+
+    Ut = (int) user;
+    St = (int) (total - user);
+
+    CUt = 0;
+    CSt = 0;
+").
+
 %-----------------------------------------------------------------------------%
 
 time.clk_tck = Ret :-

--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list