From c3938ddfd26a5d1ce1a8e34b21e0d5da2e175cbf Mon Sep 17 00:00:00 2001 From: winlin Date: Tue, 22 Dec 2020 19:24:35 +0800 Subject: [PATCH] Research: Add cost analysis --- trunk/research/st/cost.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/trunk/research/st/cost.cpp b/trunk/research/st/cost.cpp index ac6602d89..c7caeb5fa 100644 --- a/trunk/research/st/cost.cpp +++ b/trunk/research/st/cost.cpp @@ -49,6 +49,19 @@ int main(int argc, char** argv) ); } + // The cost for loop. + if (true) { + int64_t start = srs_update_system_time(); + + for (long long i = 0; i < 1000000LL; i++); + int64_t ts_loop = srs_update_system_time(); + + for (long long i = 0; i < 10000000LL; i++); + int64_t ts_loop2 = srs_update_system_time(); + + printf("[COST] loop 100w=%dus, 1000w=%dus\n", srsu2i(ts_loop - start), srsu2i(ts_loop2 - ts_loop)); + } + // The cost for printf. if (true) { int64_t start = srs_update_system_time();