Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frama-c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Charles Southerland
frama-c
Commits
07f53874
Commit
07f53874
authored
4 years ago
by
Loïc Correnson
Browse files
Options
Downloads
Patches
Plain Diff
[utils] uses try..finally pattern
parent
ac780778
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/libraries/utils/command.ml
+10
-8
10 additions, 8 deletions
src/libraries/utils/command.ml
src/libraries/utils/command.mli
+1
-3
1 addition, 3 deletions
src/libraries/utils/command.mli
with
11 additions
and
11 deletions
src/libraries/utils/command.ml
+
10
−
8
View file @
07f53874
...
...
@@ -111,21 +111,23 @@ let print_file file job =
(* -------------------------------------------------------------------------- *)
type
timer
=
float
ref
type
'
a
result
=
Result
of
'
a
|
Error
of
exn
let
dt_max
tm
dt
=
match
tm
with
Some
r
when
dt
>
!
r
->
r
:=
dt
|
_
->
()
let
dt_add
tm
dt
=
match
tm
with
Some
r
->
r
:=
!
r
+.
dt
|
_
->
()
let
return
=
function
Result
x
->
x
|
Error
e
->
raise
e
let
catch
f
x
=
try
Result
(
f
x
)
with
e
->
Error
e
let
time
?
rmax
?
radd
job
data
=
beg
in
let
t0
=
Sys
.
time
()
in
let
re
=
catch
job
data
in
let
t0
=
Sys
.
time
()
in
try
let
re
sult
=
job
data
in
let
t1
=
Sys
.
time
()
in
let
dt
=
t1
-.
t0
in
dt_max
rmax
dt
;
dt_add
radd
dt
;
return
re
;
end
result
with
exn
->
let
t1
=
Sys
.
time
()
in
let
dt
=
t1
-.
t0
in
dt_max
rmax
dt
;
dt_add
radd
dt
;
raise
exn
(* -------------------------------------------------------------------------- *)
(* --- Process --- *)
...
...
This diff is collapsed.
Click to expand it.
src/libraries/utils/command.mli
+
1
−
3
View file @
07f53874
...
...
@@ -62,9 +62,7 @@ val print_file : string -> (Format.formatter -> 'a) -> 'a
(* ************************************************************************* *)
type
timer
=
float
ref
type
'
a
result
=
Result
of
'
a
|
Error
of
exn
val
catch
:
(
'
a
->
'
b
)
->
'
a
->
'
b
result
val
return
:
'
a
result
->
'
a
val
time
:
?
rmax
:
timer
->
?
radd
:
timer
->
(
'
a
->
'
b
)
->
'
a
->
'
b
(** Compute the elapsed time with [Sys.time].
The [rmax] timer is maximized and the [radd] timer is cumulated.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment