tock / libtock-rs

Rust userland library for Tock

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is there any API function for timing?

gentooza opened this issue · comments

commented

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)

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.

commented

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