Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there any API function for timing? #532

Open
gentooza opened this issue Feb 12, 2024 · 2 comments
Open

Is there any API function for timing? #532

gentooza opened this issue Feb 12, 2024 · 2 comments

Comments

@gentooza
Copy link
Contributor

Hi!

As we are not using std we have no Instant() function, also, I've seen old code, that does not work for me using current version, using kernel::hl1::... for timer functionality

The question! (hehehe)

Is there any tool for measuring time? It could be interesting for benchmarking purposes, for example.

Thanks!
(I'm really in love with your project)

@gentooza gentooza changed the title Is there any API functions for timing? Is there any API function for timing? Feb 12, 2024
@jrvanwhy
Copy link
Collaborator

Retrieving the current time (clock ticks, to be precise) is done by using the alarm syscall driver. We do have a library for interfacing with the alarm syscall driver, but it doesn't currently appear to have a function for retrieving the current time.

You're welcome to help complete it, as it should support all functions the alarm syscall driver has.

@gentooza
Copy link
Contributor Author

gentooza commented Mar 14, 2024

Hi @jrvanwhy !

I'm going to share here the modification I have done to get Ticks back from the Alarm API component, ok?

Code is here:
https://github.com/gentooza/libtock-rs/blob/alarm_get_ticks/apis/alarm/src/lib.rs

I don't feel enough confident with Rust (yet :-D) for opening a pull request

What I have done is adding methods to struct Ticks:

  • for being able to print it:
  • for being able to make addition and subtraction operations with it
  • added a method of Alarm called get_time() to retrieve Ticks.

It's working for me, at least it gives me a coherent increasing number I can operate with. :-D

Is it ok?

Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants