Domanda

i would like to measure time how a manually triggered update task takes and for that, I would like to access the system time. How can I do this?

È stato utile?

Soluzione

Assuming that your target already has a working timer, and it gives resolution that suits you (millisecond ticks have become standard), it should be easy.

For a task that's manually triggered through u-boot COLI, there are commands that can be enabled which give time info. You wouldn't have to write any code. If these commands are not presently in your target's build, you would add to your board config file with #define.

From u-boot/README

  CONFIG_CMD_TIME    run command and report execution time
  CONFIG_CMD_TIMER   access to the system tick timer

See common/cmd_time.c and common/cmd_misc.c.

CONFIG_CMD_TIME example, if there is an update sequence defined in an environment variable:

MyTarget # time run myupdatesequence
...
time: 0.214 seconds, 214 ticks
MyTarget # 

If the events of start/stop are only visible in running code, you would write code yourself to call get_timer() and output result to console. The referenced source code is pretty clear.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top