// Copyright 2009-2020 Intel Corporation // SPDX-License-Identifier: Apache-2.0 #pragma once #include "default.h" namespace embree { /*! helper structure for the implementation of the profile functions below */ struct ProfileTimer { static const size_t N = 20; ProfileTimer () {} ProfileTimer (const size_t numSkip) : i(0), j(0), maxJ(0), numSkip(numSkip), t0(0) { for (size_t i=0; i=numSkip) { dt_min[j] = min(dt_min[j],dt); dt_avg[j] = dt_avg[j] + dt; dt_max[j] = max(dt_max[j],dt); } j++; maxJ = max(maxJ,j); } __forceinline void relative (const char* name) { const double t1 = getSeconds(); const double dt = t1-tj; tj = t1; assert(names[j] == nullptr || names[j] == name); names[j] = name; if (i == 0) dt_fst[j] = dt; if (i>=numSkip) { dt_min[j] = min(dt_min[j],dt); dt_avg[j] = dt_avg[j] + dt; dt_max[j] = max(dt_max[j],dt); } j++; maxJ = max(maxJ,j); } void print(size_t numElements) { for (size_t k=0; k void profile(const size_t numSkip, const size_t numIter, const size_t numElements, const Closure& closure) { ProfileTimer timer(numSkip); for (size_t i=0; i void profile(ProfileTimer& timer, const size_t numSkip, const size_t numIter, const size_t numElements, const Closure& closure) { timer = ProfileTimer(numSkip); for (size_t i=0; i