This is an automated email from the ASF dual-hosted git repository. xiaoxiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
commit 7ca3656c3ef352f1b7c38950b54d7867f1672be9 Author: Michal Lenc <michall...@seznam.cz> AuthorDate: Fri Jun 13 08:35:06 2025 +0200 benchmarks/osperf/osperf.c: add pipe read-write performance test This adds a simple pip read-write performance test. Signed-off-by: Michal Lenc <michall...@seznam.cz> --- benchmarks/osperf/osperf.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/benchmarks/osperf/osperf.c b/benchmarks/osperf/osperf.c index 536d55054..0e71a4e05 100644 --- a/benchmarks/osperf/osperf.c +++ b/benchmarks/osperf/osperf.c @@ -71,6 +71,7 @@ static size_t pthread_switch_performance(void); static size_t context_switch_performance(void); static size_t hpwork_performance(void); static size_t poll_performance(void); +static size_t pipe_performance(void); static size_t semwait_performance(void); static size_t sempost_performance(void); @@ -85,6 +86,7 @@ static const struct performance_entry_s g_entry_list[] = {"context-switch", context_switch_performance}, {"hpwork", hpwork_performance}, {"poll-write", poll_performance}, + {"pipe-rw", pipe_performance}, {"semwait", semwait_performance}, {"sempost", sempost_performance}, }; @@ -290,6 +292,30 @@ static size_t poll_performance(void) return performance_gettime(&result); } +/**************************************************************************** + * pipe performance + ****************************************************************************/ + +static size_t pipe_performance(void) +{ + struct performance_time_s result; + int pipefd[2]; + int ret; + char r; + + ret = pipe(pipefd); + DEBUGASSERT(ret == 0); + + performance_start(&result); + write(pipefd[0], "a", 1); + read(pipefd[1], &r, 1); + performance_end(&result); + + close(pipefd[0]); + close(pipefd[1]); + return performance_gettime(&result); +} + /**************************************************************************** * semwait_performance ****************************************************************************/