Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SWIFTsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
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
SWIFT
SWIFTsim
Commits
2ec7eca0
Commit
2ec7eca0
authored
7 years ago
by
Peter W. Draper
Browse files
Options
Downloads
Patches
Plain Diff
Add function to convert millisec into ticks
parent
a9b7c600
No related branches found
No related tags found
1 merge request
!491
Add restart facility
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/clocks.c
+19
-0
19 additions, 0 deletions
src/clocks.c
src/clocks.h
+1
-0
1 addition, 0 deletions
src/clocks.h
with
20 additions
and
0 deletions
src/clocks.c
+
19
−
0
View file @
2ec7eca0
...
...
@@ -216,6 +216,25 @@ double clocks_from_ticks(ticks tics) {
return
((
double
)
tics
/
(
double
)
clocks_get_cpufreq
()
*
clocks_units_scale
);
}
/**
* @brief Convert a number of milli seconds into ticks, if possible.
*
* Only an approximation as based on how well we have estimated the
* rtc frequency. Should be good for machines that support constant_rtc
* and clock_gettime(), and reasonable for most Linux machines, otherwise
* a guess will just be returned. See clocks_getunit() for the actual units.
*
* @param ms a number of "milliseconds" to convert to ticks
*
* @result the number of ticks, if possible.
*/
ticks
clocks_to_ticks
(
double
ms
)
{
return
(
ticks
)
(
ms
*
(
double
)
clocks_get_cpufreq
()
/
clocks_units_scale
);
}
ticks
clocks_to_ticks
(
double
interval
);
/**
* @brief return the time units.
*
...
...
This diff is collapsed.
Click to expand it.
src/clocks.h
+
1
−
0
View file @
2ec7eca0
...
...
@@ -39,6 +39,7 @@ const char *clocks_getunit();
void
clocks_set_cpufreq
(
unsigned
long
long
freq
);
unsigned
long
long
clocks_get_cpufreq
();
double
clocks_from_ticks
(
ticks
tics
);
ticks
clocks_to_ticks
(
double
interval
);
double
clocks_diff_ticks
(
ticks
tic
,
ticks
toc
);
const
char
*
clocks_get_timesincestart
();
...
...
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