void printPrettyTime() { tcputs(itoa(getHours()),COLOR_WHITE); tcputs(":",COLOR_WHITE); tcputs(itoa(getMinutes()),COLOR_WHITE); tcputs(":",COLOR_WHITE); tcputs(itoa(getSeconds()),COLOR_WHITE); tputs("\n"); }
lcRenderer::RenderJob::RenderJob (Ref<lcRenderer> renderer, const Ref<Camera>& camera, const Ref<BackendScene>& scene, const Ref<ToneMapper>& toneMapper, Ref<SwapChain > swapchain, int accumulate, int iteration) : renderer(renderer), camera(camera), scene(scene), toneMapper(toneMapper), swapchain(swapchain), accumulate(accumulate), iteration(iteration), tileID(0), atomicNumRays(0) { numTilesX = ((int)swapchain->getWidth() +TILE_SIZE-1)/TILE_SIZE; numTilesY = ((int)swapchain->getHeight()+TILE_SIZE-1)/TILE_SIZE; rcpWidth = rcp(float(swapchain->getWidth())); rcpHeight = rcp(float(swapchain->getHeight())); this->framebuffer = swapchain->buffer(); renderer->samplers->reset(); renderer->integrator->requestSamples(renderer->samplers, scene); renderer->samplers->init(iteration,renderer->filter); double tt = getSeconds(); MTLightcutter(this->scene->lcLighttree, this->scene, this->camera).Lightcut(this->swapchain, renderer->samplers->samplesPerPixel); for (size_t i = 0 ; i < swapchain->getWidth(); ++i) { for (size_t j = 0 ; j < swapchain->getHeight(); ++j) { // HACK to get the color of the pixel Color L = swapchain->update(i, j,Color(zero),0,true); const Color L1 = toneMapper->eval(L,i,j,swapchain); framebuffer->set(i, j, L1); } } double dt = getSeconds()-tt; /*! print fps, render time, and rays per second */ std::ostringstream stream; stream << "render "; stream.setf(std::ios::fixed, std::ios::floatfield); stream.precision(2); stream << 1.0f/dt << " fps, "; stream.precision(0); stream << dt*1000.0f << " ms, "; stream.precision(3); stream << atomicNumRays/dt*1E-6 << " mrps"; std::cout << stream.str() << std::endl; // delete this delete this; }
char* DS1307::getTime(void) { uint8_t seconds = getSeconds(); uint8_t minutes = getMinutes(); hours_t hours = getHours(); snprintf(timeBuf, 10, "%02d:%02d:%02d", hours.hours, minutes, seconds); return timeBuf; }
void LedTimer::_setTime() { unsigned short minutes = getMinutes(); unsigned short seconds = getSeconds(); mLedDigits[0].setNumber( minutes / 10 ); mLedDigits[1].setNumber( minutes % 10 ); mLedDigits[2].setNumber( seconds / 10 ); mLedDigits[3].setNumber( seconds % 10 ); }
Weeks *Period::toStandardWeeks() { checkYearsAndMonths("Weeks"); int64_t millis = getMillis(); // assign to a int64_t millis += ((int64_t) getSeconds()) * DateTimeConstants::MILLIS_PER_SECOND; millis += ((int64_t) getMinutes()) * DateTimeConstants::MILLIS_PER_MINUTE; millis += ((int64_t) getHours()) * DateTimeConstants::MILLIS_PER_HOUR; millis += ((int64_t) getDays()) * DateTimeConstants::MILLIS_PER_DAY; int64_t weeks = ((int64_t) getWeeks()) + millis / DateTimeConstants::MILLIS_PER_WEEK; return Weeks::weeks(FieldUtils::safeToInt(weeks)); }
Seconds *Period::toStandardSeconds() { checkYearsAndMonths("Seconds"); int64_t seconds = getMillis() / DateTimeConstants::MILLIS_PER_SECOND; seconds = FieldUtils::safeAdd(seconds, (int64_t) getSeconds()); seconds = FieldUtils::safeAdd(seconds, ((int64_t) getMinutes()) * ((int64_t) DateTimeConstants::SECONDS_PER_MINUTE)); seconds = FieldUtils::safeAdd(seconds, ((int64_t) getHours()) * ((int64_t) DateTimeConstants::SECONDS_PER_HOUR)); seconds = FieldUtils::safeAdd(seconds, ((int64_t) getDays()) * ((int64_t) DateTimeConstants::SECONDS_PER_DAY)); seconds = FieldUtils::safeAdd(seconds, ((int64_t) getWeeks()) * ((int64_t) DateTimeConstants::SECONDS_PER_WEEK)); return Seconds::seconds(FieldUtils::safeToInt(seconds)); }
Duration *Period::toStandardDuration() { checkYearsAndMonths("Duration"); int64_t millis = getMillis(); // no overflow can happen, even with Integer.MAX_VALUEs millis += (((int64_t) getSeconds()) * ((int64_t) DateTimeConstants::MILLIS_PER_SECOND)); millis += (((int64_t) getMinutes()) * ((int64_t) DateTimeConstants::MILLIS_PER_MINUTE)); millis += (((int64_t) getHours()) * ((int64_t) DateTimeConstants::MILLIS_PER_HOUR)); millis += (((int64_t) getDays()) * ((int64_t) DateTimeConstants::MILLIS_PER_DAY)); millis += (((int64_t) getWeeks()) * ((int64_t) DateTimeConstants::MILLIS_PER_WEEK)); return new Duration(millis); }
void Renderer::update() { if(resetAccumulation) { accumulation = 0; resetAccumulation = false; } if(numPassesMax > 0 && accumulation >= numPassesMax) return; updateCamera(); double t = getSeconds(); device->rtRenderFrame(renderer, camera, render_scene, tonemapper, frameBuffer, accumulation); lastRenderTime = getSeconds() - t; accumulatedTime += lastRenderTime; device->rtSwapBuffers(frameBuffer); accumulation++; }
uint32_t TimeStamp::getMonth() const { const int32_t seconds = getSeconds(); const int32_t daysSince01011970 = seconds / (60*60*24); const int32_t yearsSince01011970 = daysSince01011970 / 365; uint32_t additionalLeapDays = 0; uint32_t year = 1970; for(int32_t i = 0; i < yearsSince01011970; i++) { if (isLeapYear(year)) { additionalLeapDays++; } year++; } const int32_t days = daysSince01011970 - yearsSince01011970*365 - additionalLeapDays; uint32_t month = 1; if (days < TimeStamp::December) { month = 12; } if (days < TimeStamp::November) { month = 11; } if (days < TimeStamp::October) { month = 10; } if (days < TimeStamp::September) { month = 9; } if (days < TimeStamp::August) { month = 8; } if (days < TimeStamp::July) { month = 7; } if (days < TimeStamp::June) { month = 6; } if (days < TimeStamp::May) { month = 5; } if (days < TimeStamp::April) { month = 4; } if (days < TimeStamp::March) { month = 3; } if (days < TimeStamp::February) { month = 2; } if (days < TimeStamp::January) { month = 1; } return month; }
int RootOperationData::copyAttr(const std::string& name, Element & attr) const { if (name == SERIALNO_ATTR) { attr = getSerialno(); return 0; } if (name == REFNO_ATTR) { attr = getRefno(); return 0; } if (name == FROM_ATTR) { attr = getFrom(); return 0; } if (name == TO_ATTR) { attr = getTo(); return 0; } if (name == SECONDS_ATTR) { attr = getSeconds(); return 0; } if (name == FUTURE_SECONDS_ATTR) { attr = getFutureSeconds(); return 0; } if (name == ARGS_ATTR) { attr = getArgsAsList(); return 0; } return RootData::copyAttr(name, attr); }
void consoleService() { char ch ; ch = readKey(); if ( ch < 1 ) { ch = readServer(); if (ch < 1) return; } if ( controlMode(ch) ) { p(" -> %02d:%02d:%02d ", getHours(), getMinutes(), getSeconds() ); } }
void renderToFile(const FileName& fileName) { resize(g_width,g_height); if (g_anim_mode) g_camera.anim = true; do { double msec = getSeconds(); AffineSpace3fa pixel2world = g_camera.pixel2world(g_width,g_height); render(0.0f,pixel2world.l.vx,pixel2world.l.vy,pixel2world.l.vz,pixel2world.p); msec = getSeconds() - msec; std::cout << "render time " << 1.0/msec << " fps" << std::endl; } while(g_loop_mode); void* ptr = map(); Ref<Image> image = new Image4uc(g_width, g_height, (Col4uc*)ptr); storeImage(image, fileName); unmap(); cleanup(); }
Days *Period::toStandardDays() { checkYearsAndMonths("Days"); int64_t millis = getMillis(); // assign to a int64_t millis += ((int64_t) getSeconds()) * DateTimeConstants::MILLIS_PER_SECOND; millis += ((int64_t) getMinutes()) * DateTimeConstants::MILLIS_PER_MINUTE; millis += ((int64_t) getHours()) * DateTimeConstants::MILLIS_PER_HOUR; int64_t days = millis / DateTimeConstants::MILLIS_PER_DAY; days = FieldUtils::safeAdd(days, (int64_t) getDays()); days = FieldUtils::safeAdd(days, ((int64_t) getWeeks()) * ((int64_t) DateTimeConstants::DAYS_PER_WEEK)); return Days::days(FieldUtils::safeToInt(days)); }
Minutes *Period::toStandardMinutes() { checkYearsAndMonths("Minutes"); int64_t millis = getMillis(); // assign to a int64_t millis += ((int64_t) getSeconds()) * DateTimeConstants::MILLIS_PER_SECOND; int64_t minutes = millis / DateTimeConstants::MILLIS_PER_MINUTE; minutes = FieldUtils::safeAdd(minutes, (int64_t) getMinutes()); minutes = FieldUtils::safeAdd(minutes, ((int64_t) getHours()) * ((int64_t) DateTimeConstants::MINUTES_PER_HOUR)); minutes = FieldUtils::safeAdd(minutes, ((int64_t) getDays()) * ((int64_t) DateTimeConstants::MINUTES_PER_DAY)); minutes = FieldUtils::safeAdd(minutes, ((int64_t) getWeeks()) * ((int64_t) DateTimeConstants::MINUTES_PER_WEEK)); return Minutes::minutes(FieldUtils::safeToInt(minutes)); }
bool operator() () { bool passed = true; printf("%s::%s ... ",TOSTRING(isa),name); fflush(stdout); const size_t M = 10; for (size_t N=10; N<10000000; N*=2.1f) { /* sequentially calculate sum of squares */ size_t sum0 = 0; for (size_t i=0; i<N; i++) { sum0 += i*i; } /* parallel calculation of sum of squares */ double t0 = getSeconds(); for (size_t m=0; m<M; m++) { size_t sum1 = parallel_reduce( size_t(0), size_t(N), size_t(1024), size_t(0), [&](const range<size_t>& r) -> size_t { size_t s = 0; for (size_t i=r.begin(); i<r.end(); i++) s += i*i; return s; }, [](const size_t v0, const size_t v1) { return v0+v1; }); passed = sum0 == sum1; } double t1 = getSeconds(); printf("%zu/%3.2fM ",N,1E-6*double(N*M)/(t1-t0)); } /* output if test passed or not */ if (passed) printf("[passed]\n"); else printf("[failed]\n"); return passed; }
double BVH4::preBuild(const char* builderName) { if (builderName == nullptr) return inf; if (State::instance()->verbosity(1)) std::cout << "building BVH4<" << primTy.name << "> using " << builderName << " ..." << std::flush; double t0 = 0.0; if (State::instance()->benchmark || State::instance()->verbosity(1)) t0 = getSeconds(); return t0; }
/* get time in string format * default format is: * "hh:mm::ss'ddd", * where: * hh - hour, * mm - minures, * ss - seconds, * ddd - miliseconds. */ rfc::String rfc::Time::getTimeString() const { /* if (isInfinity) return QString("infinity"); */ return String::toString(getHours()) + QString(":") + String::toString(getMinutes()) + QString(":") + String::toString(getSeconds()) + QString("'") + String::toString(getMilliSec()); } /* end of 'Time::getTimeString' function */
double BVHN<N>::preBuild(const std::string& builderName) { if (builderName == "") return inf; if (device->verbosity(1)) std::cout << "building BVH" << N << "<" << primTy.name << "> using " << builderName << " ..." << std::flush; double t0 = 0.0; if (device->benchmark || device->verbosity(1)) t0 = getSeconds(); return t0; }
void InputControl::processEvents(void) { Lock<MutexSys> lock(inputControlMutex); if (UNLIKELY(inputControl == NULL)) { init(); this->dt = inf; this->time = lastTime = getSeconds(); } else { this->time = getSeconds(); this->dt = this->time - lastTime; lastTime = this->time; } inputControl = this; glutMainLoopEvent(); glutWarpPointer(this->w/2, this->h/2); const int w0 = glutGet(GLUT_WINDOW_WIDTH); const int h0 = glutGet(GLUT_WINDOW_HEIGHT); if (w0 != this->w || h0 != this->h) this->isResized = 1; this->w = w0; this->h = h0; previousInput = this; }
bool operator() () { bool passed = true; printf("%s::%s ... ",TOSTRING(isa),name); fflush(stdout); const size_t M = 10; for (size_t N=10; N<10000000; N*=2.1f) { /* initialize array with random numbers */ uint32_t sum0 = 0; std::vector<uint32_t> src(N); for (size_t i=0; i<N; i++) { sum0 += src[i] = rand(); } /* calculate parallel prefix sum */ std::vector<uint32_t> dst(N); memset(dst.data(),0,N*sizeof(uint32_t)); double t0 = getSeconds(); for (size_t i=0; i<M; i++) { uint32_t sum1 = parallel_prefix_sum(src,dst,N); passed &= (sum0 == sum1); } double t1 = getSeconds(); printf("%zu/%3.2fM ",N,1E-6*double(N*M)/(t1-t0)); /* check if prefix sum is correct */ for (size_t i=0, sum=0; i<N; sum+=src[i++]) passed &= ((uint32_t)sum == dst[i]); } /* output if test passed or not */ if (passed) printf("[passed]\n"); else printf("[failed]\n"); return passed; }
uint32_t TimeStamp::getDay() const { const int32_t seconds = getSeconds(); const int32_t daysSince01011970 = seconds / (60*60*24); const int32_t yearsSince01011970 = daysSince01011970 / 365; uint32_t additionalLeapDays = 0; uint32_t year = 1970; for(int32_t i = 0; i < yearsSince01011970; i++) { if (isLeapYear(year)) { additionalLeapDays++; } year++; } const int32_t days = daysSince01011970 - yearsSince01011970*365 - additionalLeapDays + 1; // 01.01.1970 is the 0. day. uint32_t day = days; if (days > TimeStamp::January) { day = days - TimeStamp::January; } if (days > TimeStamp::February) { day = days - TimeStamp::February; } if (days > TimeStamp::March) { day = days - TimeStamp::March; } if (days > TimeStamp::April) { day = days - TimeStamp::April; } if (days > TimeStamp::May) { day = days - TimeStamp::May; } if (days > TimeStamp::June) { day = days - TimeStamp::June; } if (days > TimeStamp::July) { day = days - TimeStamp::July; } if (days > TimeStamp::August) { day = days - TimeStamp::August; } if (days > TimeStamp::September) { day = days - TimeStamp::September; } if (days > TimeStamp::October) { day = days - TimeStamp::October; } if (days > TimeStamp::November) { day = days - TimeStamp::November; } return day; }
void renderBenchmark(const FileName& fileName) { resize(g_width,g_height); AffineSpace3fa pixel2world = g_camera.pixel2world(g_width,g_height); double dt = 0.0f; size_t numTotalFrames = g_skipBenchmarkFrames + g_numBenchmarkFrames; for (size_t i=0; i<numTotalFrames; i++) { double t0 = getSeconds(); render(0.0f,pixel2world.l.vx,pixel2world.l.vy,pixel2world.l.vz,pixel2world.p); double t1 = getSeconds(); std::cout << "frame [" << i << " / " << numTotalFrames << "] "; std::cout << 1.0/(t1-t0) << "fps "; if (i < g_skipBenchmarkFrames) std::cout << "(skipped)"; std::cout << std::endl; if (i >= g_skipBenchmarkFrames) dt += t1-t0; } std::cout << "frame [" << g_skipBenchmarkFrames << " - " << numTotalFrames << "] " << std::flush; std::cout << double(g_numBenchmarkFrames)/dt << "fps " << std::endl; std::cout << "BENCHMARK_RENDER " << double(g_numBenchmarkFrames)/dt << std::endl; }
// returns str of length 9 (with zero symbol) const char* getTimeStr(void) { static char timeStrBuff[9]; strcpy(timeStrBuff, getTimeStrHoursMinutes()); timeStrBuff[5] = ':'; const uint08 seconds = getSeconds(); timeStrBuff[6] = GET_PROGMEM_DIGIT(seconds / 10); timeStrBuff[7] = GET_PROGMEM_DIGIT(seconds % 10); timeStrBuff[8] = '\0'; return timeStrBuff; }
Time Time::operator+(const Time& time) const { unsigned int seconds = getSeconds() + time.getSeconds(); unsigned int uSeconds = getUSeconds() + time.getUSeconds(); if (uSeconds > uSecondsPerSecond) { ++seconds; uSeconds -= uSecondsPerSecond; } return Time(seconds, uSeconds); }
Time Time::operator-(const Time& time) const { if (time.getSeconds() > getSeconds() || (time.getSeconds() == getSeconds() && time.getUSeconds() > getUSeconds())) return Time(); unsigned int seconds = getSeconds() - time.getSeconds(); unsigned int uSeconds; if (time.getUSeconds() > getUSeconds()) { --seconds; uSeconds = uSecondsPerSecond - (time.getUSeconds() - getUSeconds()); } else { uSeconds = getUSeconds() - time.getUSeconds(); } return Time(seconds, uSeconds); }
bool operator() () { bool passed = true; printf("%s::%s ... ",TOSTRING(isa),name); fflush(stdout); const size_t M = 10; for (size_t N=10; N<10000000; N*=2.1f) { std::vector<Key> src(N); memset(src.data(),0,N*sizeof(Key)); std::vector<Key> tmp(N); memset(tmp.data(),0,N*sizeof(Key)); for (size_t i=0; i<N; i++) src[i] = uint64_t(rand())*uint64_t(rand()); /* calculate checksum */ Key sum0 = 0; for (size_t i=0; i<N; i++) sum0 += src[i]; /* sort numbers */ double t0 = getSeconds(); for (size_t i=0; i<M; i++) { radix_sort<Key>(src.data(),tmp.data(),N); } double t1 = getSeconds(); printf("%zu/%3.2fM ",N,1E-6*double(N*M)/(t1-t0)); /* calculate checksum */ Key sum1 = 0; for (size_t i=0; i<N; i++) sum1 += src[i]; if (sum0 != sum1) passed = false; /* check if numbers are sorted */ for (size_t i=1; i<N; i++) passed &= src[i-1] <= src[i]; } /* output if test passed or not */ if (passed) printf("[passed]\n"); else printf("[failed]\n"); return passed; }
void displayFunc(void) { AffineSpace3fa pixel2world = g_camera.pixel2world(g_width,g_height); /* render image using ISPC */ double t0 = getSeconds(); render(g_time0-t0, pixel2world.l.vx, -pixel2world.l.vy, pixel2world.l.vz+g_height*pixel2world.l.vy, pixel2world.p); double dt0 = getSeconds()-t0; if (g_display) { /* draw pixels to screen */ int* pixels = map(); //glRasterPos2i(-1, 1); //glPixelZoom(1.0f, -1.0f); glDrawPixels(g_width,g_height,GL_RGBA,GL_UNSIGNED_BYTE,pixels); glutSwapBuffers(); unmap(); } double dt1 = getSeconds()-t0; /* print frame rate */ std::ostringstream stream; stream.setf(std::ios::fixed, std::ios::floatfield); stream.precision(2); stream << "render: "; stream << 1.0f/dt0 << " fps, "; stream << dt0*1000.0f << " ms, "; stream << "display: "; stream << 1.0f/dt1 << " fps, "; stream << dt1*1000.0f << " ms, "; stream << g_width << "x" << g_height << " pixels"; std::cout << stream.str() << std::endl; }
void rtcBuildAccel(RTCGeometry* geom, const char* builderTy) { double t0 = getSeconds(); TaskScheduler::EventSync event; geom->build(&event,builderTy); event.sync(); double dt = getSeconds()-t0; /* output statistics */ if (g_verbose > 0) { std::ostringstream stream; size_t numTriangles = geom->size(); stream.setf(std::ios::fixed, std::ios::floatfield); stream.precision(0); stream << "triangles = " << numTriangles << std::endl; stream << "build time = " << dt*1000.0f << " ms" << std::endl; stream.precision(3); stream << "build performance = " << double(numTriangles)/dt*1E-6 << " Mtris/s" << std::endl; stream << "memory pool = " << double(Alloc::global.size())*1E-6 << " MB" << std::endl; std::cout << stream.str(); geom->accel->print(); } }
void Pony48Engine::move(direction dir) { m_fLastMovedSec = getSeconds(); m_bHasBoredVox = false; clearBoardAnimations(); //Wipe out any movement animations that are still playing bool moved = false; while(slide(dir)) //Slide as far as we can moved = true; moved = join(dir) || moved; //Join once while(slide(dir)) //Slide again! moved = true; if(moved) placenew(); //Create a new tile if we've successfully moved }
void BVH4BuilderTopLevel::build(size_t threadIndex, size_t threadCount) { /* delete some objects */ size_t N = scene->size(); for (size_t i=N; i<objects.size(); i++) { delete builders[i]; builders[i] = NULL; delete objects[i]; objects[i] = NULL; } /* resize object array if scene got larger */ if (objects.size() < N) { objects.resize(N); builders.resize(N); } refs.resize(N); nextRef = 0; /* sequential create of acceleration structures */ for (size_t i=0; i<N; i++) create_object(i); /* parallel build of acceleration structures */ if (N) scheduler->dispatchTask(threadIndex,threadCount,_task_build_parallel,this,N,"toplevel_build_parallel"); /* perform builds that need all threads */ for (size_t i=0; i<allThreadBuilds.size(); i++) { build(threadIndex,threadCount,allThreadBuilds[i]); } allThreadBuilds.clear(); /* ignore empty scenes */ refs.resize(nextRef); double t0 = 0.0; if (g_verbose >= 2) { std::cout << "building BVH4<" << bvh->primTy.name << "> with " << TOSTRING(isa) << "::TopLevel SAH builder ... " << std::flush; t0 = getSeconds(); } /* open all large nodes */ open_sequential(); prims.resize(refs.size()); for (size_t i=0; i<refs.size(); i++) { prims[i] = PrimRef(refs[i].bounds(),(size_t)refs[i].node); } BVH4TopLevelBuilderFastT::build(threadIndex,threadCount,prims.begin(),prims.size()); }