From 12ce081934172f7441c83d6cbd03cccb55f02454 Mon Sep 17 00:00:00 2001 From: Christian Zimmermann Date: Mon, 18 Dec 2017 19:02:43 +0100 Subject: [PATCH] remove time wasting debug remainder from index position calculation -> performance improvement by factor 10-20 --- src/multi_array_operation.h | 9 ++++++++- src/ranges/rpack_num.h | 6 ++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/multi_array_operation.h b/src/multi_array_operation.h index bb05787..d9100f0 100644 --- a/src/multi_array_operation.h +++ b/src/multi_array_operation.h @@ -325,10 +325,17 @@ namespace MultiArrayTools block(blockIndex); second.block(blockIndex); - + //size_t cnt = 0; + //std::clock_t cs = clock(); for(*mIndex = 0; mIndex->pos() != mIndex->max(); mIndex->pp(blockIndexNum) ){ + //std::clock_t c1 = clock(); get() = mSecond.get(); + //std::clock_t c2 = clock(); + //cnt += c2 - c1; } + //std::clock_t ce = clock(); + //std::cout << "total time = " << ce - cs << std::endl; + //std::cout << "calc time = " << cnt << std::endl; } template diff --git a/src/ranges/rpack_num.h b/src/ranges/rpack_num.h index 8df1a34..ffe64c9 100644 --- a/src/ranges/rpack_num.h +++ b/src/ranges/rpack_num.h @@ -167,9 +167,8 @@ namespace MultiArrayHelper template static size_t makePos(const std::tuple...>& iPtrTup) { - auto ID = std::get(iPtrTup)->id(); - return std::get(iPtrTup)->pos() + - RPackNum::makePos(iPtrTup) * std::get(iPtrTup)->max(); + const auto& idx = *std::get(iPtrTup); + return idx.pos() + RPackNum::makePos(iPtrTup) * idx.max(); } template @@ -328,7 +327,6 @@ namespace MultiArrayHelper template static size_t makePos(const std::tuple...>& iPtrTup) { - auto ID = std::get<0>(iPtrTup)->id(); return std::get<0>(iPtrTup)->pos(); }