// ======================================================================== // // Copyright 2009-2017 Intel Corporation // // // // Licensed under the Apache License, Version 2.0 (the "License"); // // you may not use this file except in compliance with the License. // // You may obtain a copy of the License at // // // // http://www.apache.org/licenses/LICENSE-2.0 // // // // Unless required by applicable law or agreed to in writing, software // // distributed under the License is distributed on an "AS IS" BASIS, // // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // // See the License for the specific language governing permissions and // // limitations under the License. // // ======================================================================== // #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