[Ur] time measurement
Gergely Buday
gbuday at gmail.com
Mon Jan 30 08:28:39 EST 2012
Ron wrote:
> The reason is that nobody needed it yet. I think the general approach is
> to only add things based on needs.
>
> That said, I did take a short look at how it could be implemented.
> Basically you just need to add something to urweb.c that calls:
> gettimeofday (see man gettimeofday).
>
> You would also add a version to urweb.js (IIRC) and then there was some
> file in which all of these functions that are listed (you can find it on
> the mailinglist) to which this symbol then should be added.
As I need it now for measuring page regeneration on the client side, I
have made the following patch:
$ hg diff
diff -r e8a84494d2c0 lib/js/urweb.js
--- a/lib/js/urweb.js Sun Jan 22 20:25:14 2012 -0500
+++ b/lib/js/urweb.js Mon Jan 30 08:19:49 2012 -0500
@@ -132,6 +132,10 @@
return Math.round((tm2 - tm1) / 1000000);
}
+function diffInMilliSeconds(tm1, tm2) {
+ return Math.round((tm2 - tm1) / 1000);
+}
+
function toSeconds(tm) {
return Math.round(tm / 1000000);
}
diff -r e8a84494d2c0 lib/ur/basis.urs
--- a/lib/ur/basis.urs Sun Jan 22 20:25:14 2012 -0500
+++ b/lib/ur/basis.urs Mon Jan 30 08:19:49 2012 -0500
@@ -161,6 +161,7 @@
val toSeconds : time -> int
val diffInSeconds : time -> time -> int
(* Earlier time first *)
+val diffInMilliSeconds : time -> time -> int
val timef : string -> time -> string (* Uses strftime() format string *)
val readUtc : string -> option time
diff -r e8a84494d2c0 src/settings.sml
--- a/src/settings.sml Sun Jan 22 20:25:14 2012 -0500
+++ b/src/settings.sml Mon Jan 30 08:19:49 2012 -0500
@@ -286,6 +286,7 @@
("toSeconds", "toSeconds"),
("addSeconds", "addSeconds"),
("diffInSeconds", "diffInSeconds"),
+ ("diffInMilliSeconds", "diffInMilliSeconds"),
("onClick", "uw_onClick"),
("onDblclick", "uw_onDblclick"),
If there was enough interest, and I found the time, I would do it for
the C side as well. It would take more care, but is indeed possible.
One question: how the conversion is handled when from rpc I get some
value from the server side and I use it in the client side?
- Gergely
More information about the Ur
mailing list