Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
tiamo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
4
Issues
4
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Maximilien COLANGE
tiamo
Commits
52571dd3
Commit
52571dd3
authored
Mar 30, 2016
by
Maximilien Colange
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a function to time another function.
parent
b09d246f
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
44 additions
and
11 deletions
+44
-11
Makefile.am
Makefile.am
+1
-0
myocamlbuild.ml
myocamlbuild.ml
+10
-9
src/_tags.in
src/_tags.in
+1
-1
src/ctime.c
src/ctime.c
+23
-0
src/time.ml
src/time.ml
+7
-0
src/uppaalta.ml
src/uppaalta.ml
+2
-1
No files found.
Makefile.am
View file @
52571dd3
...
...
@@ -18,6 +18,7 @@ all-local: tiamo
tiamo
:
src/main.native
cp
$(BUILDDIR)
/
$<
tiamo
src/main.native
:
src/ctime.o
src/main.native
:
src/timedAutomatonBuilder.o
.ml.native
:
...
...
myocamlbuild.ml
View file @
52571dd3
...
...
@@ -41,20 +41,21 @@ let _ =
flag
[
"c++"
;
"noassert"
]
(
ocaml_cxx_flags
[
"-DNDEBUG"
]);
(* hard-coding the C file and utap library seems the easiest way
* to avoid problems in object ordering at link time.
* Unfortunately, the dependency is not handled through ocamlbuild,
* but in the Makefile directly.
*)
* to avoid problems in object ordering at link time.
* Unfortunately, the dependency is not handled through ocamlbuild,
* but in the Makefile directly.
*)
let
xml_flags
=
try
Sys
.
getenv
"XML_LINK_FLAGS"
with
Not_found
->
"-lxml2"
in
flag
[
"ocaml"
;
"link"
;
"native"
]
(
S
[
P
"src/timedAutomatonBuilder.o"
;
A
"-cclib"
;
A
(
"-L"
^
(
Pathname
.
pwd
/
"utap/src"
));
A
"-cclib"
;
A
"-lutap"
;
A
"-cclib"
;
A
xml_flags
flag
[
"ocaml"
;
"link"
;
"native"
]
(
S
[
P
"src/ctime.o"
;
P
"src/timedAutomatonBuilder.o"
;
A
"-cclib"
;
A
(
"-L"
^
(
Pathname
.
pwd
/
"utap/src"
));
A
"-cclib"
;
A
"-lutap"
;
A
"-cclib"
;
A
xml_flags
]);
|
_
->
()
...
...
src/_tags.in
View file @
52571dd3
...
...
@@ -2,4 +2,4 @@
<*.c> or <*.cm{o,x}> or <main.native>: custom @OCAMLTAGS@
<main.native>: use_dynlink
<costs.ml>: pp(camlp4o pa_macro.cmo @TIAMO_MACROS@)
<timedAutomatonBuilder.c>: c++
<timedAutomatonBuilder.c>
or <ctime.c>
: c++
src/ctime.c
0 → 100644
View file @
52571dd3
extern
"C"
{
#include <caml/mlvalues.h>
#include <caml/memory.h>
#include <caml/callback.h>
}
#include <chrono>
extern
"C"
CAMLprim
value
time_measure_function
(
value
f
)
{
CAMLparam1
(
f
);
CAMLlocal1
(
res
);
std
::
chrono
::
time_point
<
std
::
chrono
::
system_clock
>
start
,
end
;
start
=
std
::
chrono
::
system_clock
::
now
();
res
=
caml_callback
(
f
,
Val_unit
);
end
=
std
::
chrono
::
system_clock
::
now
();
std
::
chrono
::
seconds
elapsed_seconds
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
seconds
>
(
end
-
start
);
CAMLreturn
(
caml_callback2
(
*
caml_named_value
(
"cb_build_pair"
),
Val_long
(
elapsed_seconds
.
count
()),
res
));
}
src/time.ml
0 → 100644
View file @
52571dd3
(**
* Executes a function and time it.
* The elapsed time is returned in seconds.
*)
external
measure_function
:
(
unit
->
'
a
)
->
int
*
'
a
=
"time_measure_function"
;;
src/uppaalta.ml
View file @
52571dd3
...
...
@@ -820,7 +820,8 @@ struct
Printf
.
printf
"Input automaton parsed, computing LU bounds
\n
"
;
flush
stdout
;
build_lu
ta
;
let
(
elapsed_seconds
,_
)
=
Time
.
measure_function
(
fun
()
->
build_lu
ta
)
in
Printf
.
printf
"Took %d seconds to compute LU bounds
\n
"
elapsed_seconds
;
ta
let
make_ta
tafile
qfile
=
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment