Reorganization of time calculating macros
Move time calculation macros from application directory to kernel directory, since it is used by a kernel component. In order to follow namespace and naming conventions, convert macros to SYS_CLOCK_HW_CYCLES_TO_NS* form. Change-Id: I96e9149c399adc363aed5095ae82a1abc78d2977 Signed-off-by: Dmitriy Korovkin <dmitriy.korovkin@windriver.com>
This commit is contained in:
parent
a789d4e97b
commit
f51049b81c
26 changed files with 66 additions and 119 deletions
|
@ -1,4 +1,4 @@
|
|||
/* clock_vars.h - variables needed needed for system clock */
|
||||
/* Variables needed needed for system clock */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2014-2015 Wind River Systems, Inc.
|
||||
|
@ -41,6 +41,7 @@ that use timer functionality.
|
|||
#define _CLOCK_VARS__H_
|
||||
|
||||
#ifndef _ASMLANGUAGE
|
||||
#include <stdint.h>
|
||||
|
||||
#define sys_clock_ticks_per_sec CONFIG_SYS_CLOCK_TICKS_PER_SEC
|
||||
#define sys_clock_hw_cycles_per_sec CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC
|
||||
|
@ -59,8 +60,24 @@ extern int sys_clock_us_per_tick;
|
|||
*/
|
||||
extern int sys_clock_hw_cycles_per_tick;
|
||||
|
||||
/* number of nsec per usec */
|
||||
#define NSEC_PER_USEC 1000
|
||||
|
||||
/* SYS_CLOCK_HW_CYCLES_TO_NS64 converts CPU clock cycles to nanoseconds */
|
||||
#define SYS_CLOCK_HW_CYCLES_TO_NS64(X) \
|
||||
(((uint64_t)(X) * sys_clock_us_per_tick * NSEC_PER_USEC) / \
|
||||
sys_clock_hw_cycles_per_tick)
|
||||
|
||||
/*
|
||||
* SYS_CLOCK_HW_CYCLES_TO_NS_AVG converts CPU clock cycles to nanoseconds
|
||||
* and calculates the average cycle time
|
||||
*/
|
||||
#define SYS_CLOCK_HW_CYCLES_TO_NS_AVG(X, NCYCLES) \
|
||||
(uint32_t)(SYS_CLOCK_HW_CYCLES_TO_NS64 (X) / NCYCLES)
|
||||
|
||||
#define SYS_CLOCK_HW_CYCLES_TO_NS(X) (uint32_t)(SYS_CLOCK_HW_CYCLES_TO_NS64 (X))
|
||||
|
||||
#ifdef CONFIG_NANOKERNEL
|
||||
#include <stdint.h>
|
||||
extern uint32_t nanoTicks;
|
||||
extern struct nano_timer *nanoTimerList;
|
||||
#endif /* CONFIG_NANOKERNEL */
|
||||
|
|
|
@ -41,7 +41,6 @@
|
|||
#include <misc/printk.h> /* printk */
|
||||
#include <clock_vars.h>
|
||||
#include <drivers/system_timer.h>
|
||||
#include <../../../../applications/benchmark/latency_measure/timemacro.h>
|
||||
|
||||
/* defines */
|
||||
|
||||
|
@ -231,25 +230,25 @@ void int_latency_show(void)
|
|||
"handler:"
|
||||
" %d tcs = %d nsec\n",
|
||||
intHandlerLatency,
|
||||
CYCLES2NS(intHandlerLatency));
|
||||
SYS_CLOCK_HW_CYCLES_TO_NS(intHandlerLatency));
|
||||
}
|
||||
|
||||
printk(" Max interrupt latency (includes hw int. to 'C' "
|
||||
"handler):"
|
||||
" %d tcs = %d nsec\n",
|
||||
intLockingLatencyMax + intHandlerLatency,
|
||||
CYCLES2NS(intLockingLatencyMax + intHandlerLatency));
|
||||
SYS_CLOCK_HW_CYCLES_TO_NS(intLockingLatencyMax + intHandlerLatency));
|
||||
|
||||
printk(" Overhead substracted from Max int. latency:\n"
|
||||
" for int. lock : %d tcs = %d nsec\n"
|
||||
" each time int. lock nest: %d tcs = %d nsec\n"
|
||||
" for int. unlocked : %d tcs = %d nsec\n",
|
||||
initialStartDelay,
|
||||
CYCLES2NS(initialStartDelay),
|
||||
SYS_CLOCK_HW_CYCLES_TO_NS(initialStartDelay),
|
||||
nestingDelay,
|
||||
CYCLES2NS(nestingDelay),
|
||||
SYS_CLOCK_HW_CYCLES_TO_NS(nestingDelay),
|
||||
stopDelay,
|
||||
CYCLES2NS(stopDelay));
|
||||
SYS_CLOCK_HW_CYCLES_TO_NS(stopDelay));
|
||||
} else {
|
||||
printk("interrupts were not locked and unlocked yet\n");
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ void event_test (void)
|
|||
check_result ();
|
||||
|
||||
PRINT_F (output_file, FORMAT, "Signal enabled event",
|
||||
CYCLES2NS_AVG (et, NR_OF_EVENT_RUNS));
|
||||
SYS_CLOCK_HW_CYCLES_TO_NS_AVG (et, NR_OF_EVENT_RUNS));
|
||||
|
||||
et = BENCH_START ();
|
||||
for (nCounter = 0; nCounter < NR_OF_EVENT_RUNS; nCounter++)
|
||||
|
@ -116,7 +116,7 @@ void event_test (void)
|
|||
check_result ();
|
||||
|
||||
PRINT_F (output_file, FORMAT, "Signal event & Test event",
|
||||
CYCLES2NS_AVG (et, NR_OF_EVENT_RUNS));
|
||||
SYS_CLOCK_HW_CYCLES_TO_NS_AVG (et, NR_OF_EVENT_RUNS));
|
||||
|
||||
et = BENCH_START ();
|
||||
for (nCounter = 0; nCounter < NR_OF_EVENT_RUNS; nCounter++)
|
||||
|
@ -142,7 +142,7 @@ void event_test (void)
|
|||
check_result ();
|
||||
|
||||
PRINT_F (output_file, FORMAT, "Signal event & TestW event",
|
||||
CYCLES2NS_AVG (et, NR_OF_EVENT_RUNS));
|
||||
SYS_CLOCK_HW_CYCLES_TO_NS_AVG (et, NR_OF_EVENT_RUNS));
|
||||
|
||||
PRINT_STRING ("| Signal event with installed handler"
|
||||
" |\n", output_file);
|
||||
|
|
|
@ -57,7 +57,7 @@ void queue_test (void)
|
|||
et = TIME_STAMP_DELTA_GET (et);
|
||||
|
||||
PRINT_F (output_file, FORMAT, "enqueue 1 byte msg in FIFO",
|
||||
CYCLES2NS_AVG (et, NR_OF_FIFO_RUNS));
|
||||
SYS_CLOCK_HW_CYCLES_TO_NS_AVG (et, NR_OF_FIFO_RUNS));
|
||||
|
||||
et = BENCH_START ();
|
||||
for (i = 0; i < NR_OF_FIFO_RUNS; i++)
|
||||
|
@ -68,7 +68,7 @@ void queue_test (void)
|
|||
check_result ();
|
||||
|
||||
PRINT_F (output_file, FORMAT, "dequeue 1 byte msg in FIFO",
|
||||
CYCLES2NS_AVG (et, NR_OF_FIFO_RUNS));
|
||||
SYS_CLOCK_HW_CYCLES_TO_NS_AVG (et, NR_OF_FIFO_RUNS));
|
||||
|
||||
et = BENCH_START ();
|
||||
for (i = 0; i < NR_OF_FIFO_RUNS; i++)
|
||||
|
@ -79,7 +79,7 @@ void queue_test (void)
|
|||
check_result ();
|
||||
|
||||
PRINT_F (output_file, FORMAT, "enqueue 4 bytes msg in FIFO",
|
||||
CYCLES2NS_AVG (et, NR_OF_FIFO_RUNS));
|
||||
SYS_CLOCK_HW_CYCLES_TO_NS_AVG (et, NR_OF_FIFO_RUNS));
|
||||
|
||||
et = BENCH_START ();
|
||||
for (i = 0; i < NR_OF_FIFO_RUNS; i++)
|
||||
|
@ -90,7 +90,7 @@ void queue_test (void)
|
|||
check_result ();
|
||||
|
||||
PRINT_F (output_file, FORMAT, "dequeue 4 bytes msg in FIFO",
|
||||
CYCLES2NS_AVG (et, NR_OF_FIFO_RUNS));
|
||||
SYS_CLOCK_HW_CYCLES_TO_NS_AVG (et, NR_OF_FIFO_RUNS));
|
||||
|
||||
task_sem_give (STARTRCV);
|
||||
|
||||
|
@ -104,7 +104,7 @@ void queue_test (void)
|
|||
|
||||
PRINT_F (output_file, FORMAT,
|
||||
"enqueue 1 byte msg in FIFO to a waiting higher priority task",
|
||||
CYCLES2NS_AVG (et, NR_OF_FIFO_RUNS));
|
||||
SYS_CLOCK_HW_CYCLES_TO_NS_AVG (et, NR_OF_FIFO_RUNS));
|
||||
|
||||
et = BENCH_START ();
|
||||
for (i = 0; i < NR_OF_FIFO_RUNS; i++)
|
||||
|
@ -116,7 +116,7 @@ void queue_test (void)
|
|||
|
||||
PRINT_F (output_file, FORMAT,
|
||||
"enqueue 4 bytes in FIFO to a waiting higher priority task",
|
||||
CYCLES2NS_AVG (et, NR_OF_FIFO_RUNS));
|
||||
SYS_CLOCK_HW_CYCLES_TO_NS_AVG (et, NR_OF_FIFO_RUNS));
|
||||
}
|
||||
|
||||
#endif /* FIFO_BENCH */
|
||||
|
|
|
@ -172,7 +172,7 @@ void mailbox_put (
|
|||
task_mbox_put_wait (MAILB1, 1, &Message);
|
||||
}
|
||||
t = TIME_STAMP_DELTA_GET (t);
|
||||
*time = CYCLES2NS_AVG (t, count);
|
||||
*time = SYS_CLOCK_HW_CYCLES_TO_NS_AVG (t, count);
|
||||
check_result ();
|
||||
}
|
||||
|
||||
|
|
|
@ -115,7 +115,7 @@ int mailbox_get (
|
|||
}
|
||||
|
||||
t = TIME_STAMP_DELTA_GET (t);
|
||||
*time = CYCLES2NS_AVG (t, count);
|
||||
*time = SYS_CLOCK_HW_CYCLES_TO_NS_AVG (t, count);
|
||||
if (bench_test_end () < 0)
|
||||
PRINT_OVERFLOW_ERROR ();
|
||||
return 0;
|
||||
|
|
|
@ -63,7 +63,7 @@ void memorymap_test (void)
|
|||
check_result ();
|
||||
|
||||
PRINT_F (output_file, FORMAT, "average alloc and dealloc memory page",
|
||||
CYCLES2NS_AVG (et, (2 * NR_OF_MAP_RUNS)));
|
||||
SYS_CLOCK_HW_CYCLES_TO_NS_AVG (et, (2 * NR_OF_MAP_RUNS)));
|
||||
#endif /* MEMMAP_LITE */
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ void mempool_test (void)
|
|||
|
||||
PRINT_F (output_file, FORMAT,
|
||||
"average alloc and dealloc memory pool block",
|
||||
CYCLES2NS_AVG (et, (2 * NR_OF_POOL_RUNS)));
|
||||
SYS_CLOCK_HW_CYCLES_TO_NS_AVG (et, (2 * NR_OF_POOL_RUNS)));
|
||||
}
|
||||
|
||||
#endif /* MEMPOOL_BENCH */
|
||||
|
|
|
@ -59,7 +59,7 @@ void mutex_test (void)
|
|||
check_result ();
|
||||
|
||||
PRINT_F (output_file, FORMAT, "average lock and unlock mutex",
|
||||
CYCLES2NS_AVG (et, (2 * NR_OF_MUTEX_RUNS)));
|
||||
SYS_CLOCK_HW_CYCLES_TO_NS_AVG (et, (2 * NR_OF_MUTEX_RUNS)));
|
||||
}
|
||||
|
||||
#endif /* MUTEX_BENCH */
|
||||
|
|
|
@ -57,7 +57,7 @@ void call_test (void)
|
|||
check_result ();
|
||||
|
||||
PRINT_F (output_file, FORMAT, "minimum VxMicro call time",
|
||||
CYCLES2NS_AVG (et, NR_OF_NOP_RUNS));
|
||||
SYS_CLOCK_HW_CYCLES_TO_NS_AVG (et, NR_OF_NOP_RUNS));
|
||||
}
|
||||
|
||||
#endif /* MICROKERNEL_CALL_BENCH */
|
||||
|
|
|
@ -267,7 +267,7 @@ int pipeput (
|
|||
}
|
||||
|
||||
t = TIME_STAMP_DELTA_GET (t);
|
||||
*time = CYCLES2NS_AVG (t, count);
|
||||
*time = SYS_CLOCK_HW_CYCLES_TO_NS_AVG (t, count);
|
||||
if (bench_test_end () < 0)
|
||||
{
|
||||
if (high_timer_overflow ())
|
||||
|
|
|
@ -164,7 +164,7 @@ int pipeget (
|
|||
}
|
||||
|
||||
t = TIME_STAMP_DELTA_GET (t);
|
||||
*time = CYCLES2NS_AVG (t, count);
|
||||
*time = SYS_CLOCK_HW_CYCLES_TO_NS_AVG (t, count);
|
||||
if (bench_test_end () < 0)
|
||||
{
|
||||
if (high_timer_overflow ())
|
||||
|
|
|
@ -59,7 +59,7 @@ void sema_test (void)
|
|||
check_result ();
|
||||
|
||||
PRINT_F (output_file, FORMAT, "signal semaphore",
|
||||
CYCLES2NS_AVG (et, NR_OF_SEMA_RUNS));
|
||||
SYS_CLOCK_HW_CYCLES_TO_NS_AVG (et, NR_OF_SEMA_RUNS));
|
||||
|
||||
task_sem_reset (SEM1);
|
||||
task_sem_give (STARTRCV);
|
||||
|
@ -73,7 +73,7 @@ void sema_test (void)
|
|||
check_result ();
|
||||
|
||||
PRINT_F (output_file, FORMAT, "signal to waiting high pri task",
|
||||
CYCLES2NS_AVG (et, NR_OF_SEMA_RUNS));
|
||||
SYS_CLOCK_HW_CYCLES_TO_NS_AVG (et, NR_OF_SEMA_RUNS));
|
||||
|
||||
#ifndef SEMA_LITE
|
||||
et = BENCH_START ();
|
||||
|
@ -86,7 +86,7 @@ void sema_test (void)
|
|||
|
||||
PRINT_F (output_file, FORMAT,
|
||||
"signal to waiting high pri task, with timeout",
|
||||
CYCLES2NS_AVG (et, NR_OF_SEMA_RUNS));
|
||||
SYS_CLOCK_HW_CYCLES_TO_NS_AVG (et, NR_OF_SEMA_RUNS));
|
||||
|
||||
et = BENCH_START ();
|
||||
for (i = 0; i < NR_OF_SEMA_RUNS; i++)
|
||||
|
@ -97,7 +97,7 @@ void sema_test (void)
|
|||
check_result ();
|
||||
|
||||
PRINT_F (output_file, FORMAT, "signal to waitm (2)",
|
||||
CYCLES2NS_AVG (et, NR_OF_SEMA_RUNS));
|
||||
SYS_CLOCK_HW_CYCLES_TO_NS_AVG (et, NR_OF_SEMA_RUNS));
|
||||
|
||||
et = BENCH_START ();
|
||||
for (i = 0; i < NR_OF_SEMA_RUNS; i++)
|
||||
|
@ -108,7 +108,7 @@ void sema_test (void)
|
|||
check_result ();
|
||||
|
||||
PRINT_F (output_file, FORMAT, "signal to waitm (2), with timeout",
|
||||
CYCLES2NS_AVG (et, NR_OF_SEMA_RUNS));
|
||||
SYS_CLOCK_HW_CYCLES_TO_NS_AVG (et, NR_OF_SEMA_RUNS));
|
||||
|
||||
et = BENCH_START ();
|
||||
for (i = 0; i < NR_OF_SEMA_RUNS; i++)
|
||||
|
@ -119,7 +119,7 @@ void sema_test (void)
|
|||
check_result ();
|
||||
|
||||
PRINT_F (output_file, FORMAT, "signal to waitm (3)",
|
||||
CYCLES2NS_AVG (et, NR_OF_SEMA_RUNS));
|
||||
SYS_CLOCK_HW_CYCLES_TO_NS_AVG (et, NR_OF_SEMA_RUNS));
|
||||
|
||||
et = BENCH_START ();
|
||||
for (i = 0; i < NR_OF_SEMA_RUNS; i++)
|
||||
|
@ -130,7 +130,7 @@ void sema_test (void)
|
|||
check_result ();
|
||||
|
||||
PRINT_F (output_file, FORMAT, "signal to waitm (3), with timeout",
|
||||
CYCLES2NS_AVG (et, NR_OF_SEMA_RUNS));
|
||||
SYS_CLOCK_HW_CYCLES_TO_NS_AVG (et, NR_OF_SEMA_RUNS));
|
||||
|
||||
et = BENCH_START ();
|
||||
for (i = 0; i < NR_OF_SEMA_RUNS; i++)
|
||||
|
@ -141,7 +141,7 @@ void sema_test (void)
|
|||
check_result ();
|
||||
|
||||
PRINT_F (output_file, FORMAT, "signal to waitm (4)",
|
||||
CYCLES2NS_AVG (et, NR_OF_SEMA_RUNS));
|
||||
SYS_CLOCK_HW_CYCLES_TO_NS_AVG (et, NR_OF_SEMA_RUNS));
|
||||
|
||||
et = BENCH_START ();
|
||||
for (i = 0; i < NR_OF_SEMA_RUNS; i++)
|
||||
|
@ -152,7 +152,7 @@ void sema_test (void)
|
|||
check_result ();
|
||||
|
||||
PRINT_F (output_file, FORMAT, "signal to waitm (4), with timeout",
|
||||
CYCLES2NS_AVG (et, NR_OF_SEMA_RUNS));
|
||||
SYS_CLOCK_HW_CYCLES_TO_NS_AVG (et, NR_OF_SEMA_RUNS));
|
||||
#endif /* SEMA_LITE */
|
||||
}
|
||||
|
||||
|
|
|
@ -108,7 +108,7 @@ int microIntToTask (void)
|
|||
if (flagVar == 1)
|
||||
{
|
||||
PRINT_FORMAT (" switching time is %lu tcs = %lu nsec",
|
||||
timestamp, CYCLES2NS(timestamp));
|
||||
timestamp, SYS_CLOCK_HW_CYCLES_TO_NS(timestamp));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -106,7 +106,7 @@ int microIntToTaskEvt (void)
|
|||
task_event_recv_wait (EVENT0);
|
||||
timestamp = TIME_STAMP_DELTA_GET (timestamp);
|
||||
PRINT_FORMAT (" switch time is %lu tcs = %lu nsec",
|
||||
timestamp, CYCLES2NS (timestamp));
|
||||
timestamp, SYS_CLOCK_HW_CYCLES_TO_NS (timestamp));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ int microSemaLockUnlock (void)
|
|||
{
|
||||
PRINT_FORMAT (" Average semaphore signal time %lu tcs = %lu nsec",
|
||||
timestamp / N_TEST_SEMA,
|
||||
CYCLES2NS_AVG (timestamp, N_TEST_SEMA));
|
||||
SYS_CLOCK_HW_CYCLES_TO_NS_AVG (timestamp, N_TEST_SEMA));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -101,7 +101,7 @@ int microSemaLockUnlock (void)
|
|||
{
|
||||
PRINT_FORMAT (" Average semaphore test time %lu tcs = %lu nsec",
|
||||
timestamp / N_TEST_SEMA,
|
||||
CYCLES2NS_AVG (timestamp, N_TEST_SEMA));
|
||||
SYS_CLOCK_HW_CYCLES_TO_NS_AVG (timestamp, N_TEST_SEMA));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -137,7 +137,7 @@ int microMutexLockUnlock (void)
|
|||
timestamp = TIME_STAMP_DELTA_GET (timestamp);
|
||||
PRINT_FORMAT (" Average time to lock the mutex %lu tcs = %lu nsec",
|
||||
timestamp / N_TEST_MUTEX,
|
||||
CYCLES2NS_AVG (timestamp, N_TEST_MUTEX));
|
||||
SYS_CLOCK_HW_CYCLES_TO_NS_AVG (timestamp, N_TEST_MUTEX));
|
||||
timestamp = TIME_STAMP_DELTA_GET (0);
|
||||
for (i = 0; i <= N_TEST_MUTEX; i++)
|
||||
{
|
||||
|
@ -146,7 +146,7 @@ int microMutexLockUnlock (void)
|
|||
timestamp = TIME_STAMP_DELTA_GET (timestamp);
|
||||
PRINT_FORMAT (" Average time to unlock the mutex %lu tcs = %lu nsec",
|
||||
timestamp / N_TEST_MUTEX,
|
||||
CYCLES2NS_AVG (timestamp, N_TEST_MUTEX));
|
||||
SYS_CLOCK_HW_CYCLES_TO_NS_AVG (timestamp, N_TEST_MUTEX));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -135,7 +135,7 @@ void microTaskSwitchYield (void)
|
|||
PRINT_FORMAT (" Average task context switch using "
|
||||
"yield %lu tcs = %lu nsec",
|
||||
timestamp / (iterations + helper_task_iterations),
|
||||
CYCLES2NS_AVG (timestamp,
|
||||
SYS_CLOCK_HW_CYCLES_TO_NS_AVG (timestamp,
|
||||
(iterations + helper_task_iterations)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -145,6 +145,6 @@ int nanoCtxSwitch (void)
|
|||
else
|
||||
PRINT_FORMAT (" Average context switch time is %lu tcs = %lu nsec",
|
||||
timestamp / ctxSwitchCounter,
|
||||
CYCLES2NS_AVG (timestamp, ctxSwitchCounter));
|
||||
SYS_CLOCK_HW_CYCLES_TO_NS_AVG (timestamp, ctxSwitchCounter));
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -101,6 +101,6 @@ int nanoIntLatency (void)
|
|||
task_fiber_start (&fiberStack[0], STACKSIZE,
|
||||
(nano_fiber_entry_t) fiberInt, 0, 0, 6, 0);
|
||||
PRINT_FORMAT (" switching time is %lu tcs = %lu nsec",
|
||||
timestamp, CYCLES2NS (timestamp));
|
||||
timestamp, SYS_CLOCK_HW_CYCLES_TO_NS (timestamp));
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ int nanoIntLockUnlock (void)
|
|||
{
|
||||
PRINT_FORMAT (" Average time for lock then unlock "
|
||||
"is %lu tcs = %lu nsec",
|
||||
timestamp / NTESTS, CYCLES2NS_AVG (timestamp, NTESTS));
|
||||
timestamp / NTESTS, SYS_CLOCK_HW_CYCLES_TO_NS_AVG (timestamp, NTESTS));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -101,7 +101,7 @@ int nanoIntLockUnlock (void)
|
|||
{
|
||||
PRINT_FORMAT (" Average time for lock then unlock "
|
||||
"is %lu tcs = %lu nsec",
|
||||
timestamp / NTESTS, CYCLES2NS_AVG (timestamp, NTESTS));
|
||||
timestamp / NTESTS, SYS_CLOCK_HW_CYCLES_TO_NS_AVG (timestamp, NTESTS));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -113,7 +113,7 @@ int nanoIntToFiber (void)
|
|||
if (flagVar == 1)
|
||||
{
|
||||
PRINT_FORMAT (" switching time is %lu tcs = %lu nsec",
|
||||
timestamp, CYCLES2NS (timestamp));
|
||||
timestamp, SYS_CLOCK_HW_CYCLES_TO_NS (timestamp));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -139,6 +139,6 @@ int nanoIntToFiberSem (void)
|
|||
(nano_fiber_entry_t) fiberInt, 0, 0, 6, 0);
|
||||
|
||||
PRINT_FORMAT (" switching time is %lu tcs = %lu nsec",
|
||||
timestamp, CYCLES2NS (timestamp));
|
||||
timestamp, SYS_CLOCK_HW_CYCLES_TO_NS (timestamp));
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,66 +0,0 @@
|
|||
/* timemacro.h - time conversion macroses */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2012, 2014 Wind River Systems, Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1) Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2) Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3) Neither the name of Wind River Systems nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* DESCRIPTION
|
||||
* This file contains the macroses for converting time for
|
||||
* benchmarking tests.
|
||||
*/
|
||||
|
||||
#ifndef _TIMEMACRO_H_
|
||||
#define _TIMEMACRO_H_
|
||||
|
||||
#if defined (CONFIG_NANOKERNEL)
|
||||
#include <nanokernel.h>
|
||||
#elif defined (CONFIG_MICROKERNEL)
|
||||
#include <microkernel.h>
|
||||
#else
|
||||
#error either CONFIG_NANOKERNEL or CONFIG_MICROKERNEL must be defined
|
||||
#endif /* CONFIG_NANOKERNEL */
|
||||
|
||||
/* number of nsec per usec */
|
||||
#define NSEC_PER_USEC 1000
|
||||
|
||||
/* CYCLES2NS64 converts CPU clock cycles to nanoseconds */
|
||||
#define CYCLES2NS64(X) \
|
||||
(((uint64_t)(X) * sys_clock_us_per_tick * NSEC_PER_USEC) / \
|
||||
sys_clock_hw_cycles_per_tick)
|
||||
|
||||
/*
|
||||
* CYCLES2NS_AVG converts CPU clock cycles to nanoseconds and calculates
|
||||
* the average cycle time
|
||||
*/
|
||||
#define CYCLES2NS_AVG(X, NCYCLES) (uint32_t)(CYCLES2NS64 (X) / NCYCLES)
|
||||
|
||||
#define CYCLES2NS(X) (uint32_t)(CYCLES2NS64 (X))
|
||||
|
||||
#endif /* _TIMEMACRO_H_ */
|
|
@ -41,9 +41,6 @@
|
|||
|
||||
#include <limits.h>
|
||||
|
||||
#include <timemacro.h>
|
||||
|
||||
|
||||
#if defined (CONFIG_NANOKERNEL)
|
||||
|
||||
#include <nanokernel.h>
|
||||
|
@ -66,6 +63,7 @@ static inline void TICK_SYNCH (void)
|
|||
}
|
||||
|
||||
#elif (defined (CONFIG_MICROKERNEL) && defined (KERNEL))
|
||||
#include <vxmicro.h>
|
||||
|
||||
#define OS_GET_TIME() task_node_cycle_get_32 ()
|
||||
|
||||
|
@ -125,7 +123,6 @@ static inline void bench_test_init (void)
|
|||
}
|
||||
|
||||
#if defined (CONFIG_MICROKERNEL) && defined (KERNEL)
|
||||
#include <vxmicro.h>
|
||||
|
||||
/* number of ticks before timer overflows */
|
||||
#define BENCH_MAX_TICKS (sys_clock_ticks_per_sec - 1)
|
||||
|
|
|
@ -92,7 +92,7 @@ static inline void printDashLine (void)
|
|||
printDashLine ();
|
||||
|
||||
#define PRINT_TIME_BANNER() \
|
||||
PRINT_FORMAT(" tcs = timer clock cycles: 1 tcs is %lu nsec", CYCLES2NS(1));\
|
||||
PRINT_FORMAT(" tcs = timer clock cycles: 1 tcs is %lu nsec", SYS_CLOCK_HW_CYCLES_TO_NS(1));\
|
||||
printDashLine ();
|
||||
|
||||
#define PRINT_OVERFLOW_ERROR() \
|
||||
|
|
|
@ -133,7 +133,7 @@ int check_result (
|
|||
fprintf (output_file, sz_case_details_fmt,
|
||||
"Average time for 1 iteration: ");
|
||||
fprintf (output_file, sz_case_timing_fmt,
|
||||
CYCLES2NS_AVG(t, NUMBER_OF_LOOPS));
|
||||
SYS_CLOCK_HW_CYCLES_TO_NS_AVG(t, NUMBER_OF_LOOPS));
|
||||
|
||||
fprintf (output_file, sz_case_end_fmt);
|
||||
return 1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue