本文整理汇总了C++中poco::Timestamp::elapsed方法的典型用法代码示例。如果您正苦于以下问题:C++ Timestamp::elapsed方法的具体用法?C++ Timestamp::elapsed怎么用?C++ Timestamp::elapsed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类poco::Timestamp
的用法示例。
在下文中一共展示了Timestamp::elapsed方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testPerformance
void TileCacheTests::testPerformance()
{
std::string documentPath, documentURL;
getDocumentPathAndURL("hello.odt", documentPath, documentURL);
Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, documentURL);
auto socket = *loadDocAndGetSocket(_uri, documentURL, "tile-performance ");
getResponseMessage(socket, "invalidatetiles:");
Poco::Timestamp timestamp;
for (auto x = 0; x < 5; ++x)
{
sendTextFrame(socket, "tilecombine part=0 width=256 height=256 tileposx=0,3840,7680,11520,0,3840,7680,11520 tileposy=0,0,0,0,3840,3840,3840,3840 tilewidth=3840 tileheight=3840");
for (auto i = 0; i < 8; ++i)
{
auto tile = getResponseMessage(socket, "tile:", "tile-performance ");
CPPUNIT_ASSERT_MESSAGE("did not receive a tile: message as expected", !tile.empty());
}
}
std::cerr << "Tile rendering roundtrip for 5 x 8 tiles combined: " << timestamp.elapsed() / 1000.
<< " ms. Per-tilecombine: " << timestamp.elapsed() / (1000. * 5)
<< " ms. Per-tile: " << timestamp.elapsed() / (1000. * 5 * 8) << "ms."
<< std::endl;
socket.shutdown();
}
示例2: LOGNS
int
FFmpegTagger::IORead(void *opaque, uint8_t *buf, int buf_size)
{
URLContext* pUrlContext = (URLContext*)opaque;
std::istream* pInputStream = (std::istream*)pUrlContext->priv_data;
if (!pInputStream) {
LOGNS(Omm::AvStream, avstream, error, "IORead failed, std::istream not set");
return -1;
}
pInputStream->read((char*)buf, buf_size);
Poco::Timestamp::TimeDiff time = _timestamp.elapsed();
_timestamp.update();
Poco::Timestamp::TimeDiff startTime = _startTimestamp.elapsed();
int bytes = pInputStream->gcount();
_totalBytes += bytes;
if (!pInputStream->good()) {
LOGNS(Omm::AvStream, avstream, error, "IORead failed to read from std::istream");
return -1;
}
LOGNS(Omm::AvStream, avstream, trace, "IORead() bytes read: " + Poco::NumberFormatter::format(bytes) + " in " + Poco::NumberFormatter::format(time/1000.0, 3) + " msec (" + Poco::NumberFormatter::format(bytes*1000/time) + " kB/s), total : " +\
Poco::NumberFormatter::format(_totalBytes/1000) + "kB in " + Poco::NumberFormatter::format(startTime/(Poco::Timestamp::TimeDiff)1000000) + " sec (" + Poco::NumberFormatter::format((Poco::Timestamp::TimeDiff)(_totalBytes*1000)/startTime) + "kB/s)");
return bytes;
}
示例3: sleepImpl
void ThreadImpl::sleepImpl(long milliseconds)
{
#if defined(__digital__)
// This is specific to DECThreads
struct timespec interval;
interval.tv_sec = milliseconds / 1000;
interval.tv_nsec = (milliseconds % 1000)*1000000;
pthread_delay_np(&interval);
#elif POCO_OS == POCO_OS_LINUX || POCO_OS == POCO_OS_ANDROID || POCO_OS == POCO_OS_MAC_OS_X || POCO_OS == POCO_OS_QNX || POCO_OS == POCO_OS_VXWORKS
Poco::Timespan remainingTime(1000*Poco::Timespan::TimeDiff(milliseconds));
int rc;
do
{
struct timespec ts;
ts.tv_sec = (long) remainingTime.totalSeconds();
ts.tv_nsec = (long) remainingTime.useconds()*1000;
Poco::Timestamp start;
rc = ::nanosleep(&ts, 0);
if (rc < 0 && errno == EINTR)
{
Poco::Timestamp end;
Poco::Timespan waited = start.elapsed();
if (waited < remainingTime)
remainingTime -= waited;
else
remainingTime = 0;
}
}
while (remainingTime > 0 && rc < 0 && errno == EINTR);
if (rc < 0 && remainingTime > 0) throw Poco::SystemException("Thread::sleep(): nanosleep() failed");
#else
Poco::Timespan remainingTime(1000*Poco::Timespan::TimeDiff(milliseconds));
int rc;
do
{
struct timeval tv;
tv.tv_sec = (long) remainingTime.totalSeconds();
tv.tv_usec = (long) remainingTime.useconds();
Poco::Timestamp start;
rc = ::select(0, NULL, NULL, NULL, &tv);
if (rc < 0 && errno == EINTR)
{
Poco::Timestamp end;
Poco::Timespan waited = start.elapsed();
if (waited < remainingTime)
remainingTime -= waited;
else
remainingTime = 0;
}
}
while (remainingTime > 0 && rc < 0 && errno == EINTR);
if (rc < 0 && remainingTime > 0) throw Poco::SystemException("Thread::sleep(): select() failed");
#endif
}
示例4: testSleep
void ThreadTest::testSleep()
{
Poco::Timestamp start;
Thread::sleep(200);
Poco::Timespan elapsed = start.elapsed();
assert (elapsed.totalMilliseconds() >= 190 && elapsed.totalMilliseconds() < 250);
}
示例5: StartupStore
void StartupStore(const TCHAR *Str, ...)
{
TCHAR buf[(MAX_PATH*2)+1]; // 260 chars normally FIX 100205
va_list ap;
va_start(ap, Str);
_vsntprintf(buf, countof(buf), Str, ap);
va_end(ap);
LockStartupStore();
FILE *startupStoreFile = NULL;
static TCHAR szFileName[MAX_PATH];
static Poco::Timestamp StartTime;
static bool initialised = false;
if (!initialised) {
LocalPath(szFileName, TEXT(LKF_RUNLOG));
initialised = true;
}
startupStoreFile = _tfopen(szFileName, TEXT("ab+"));
if (startupStoreFile != NULL) {
char sbuf[(MAX_PATH*2)+1]; // FIX 100205
int i = TCHAR2utf(buf, sbuf, sizeof(sbuf));
if (i > 0) {
if (sbuf[i - 1] == 0x0a && (i == 1 || (i > 1 && sbuf[i-2] != 0x0d)))
sprintf(sbuf + i - 1, SNEWLINE);
fprintf(startupStoreFile, "[%09u] %s", (unsigned int)StartTime.elapsed()/1000, sbuf);
}
fclose(startupStoreFile);
}
UnlockStartupStore();
}
示例6: evaluateBaseline
void TemplateMatchingTrainer::evaluateBaseline(const std::string &meanForAlign, const std::string &dataPath, const std::string &pcaDepthmapPath)
{
FaceAligner aligner(Mesh::fromFile(meanForAlign), std::string());
std::vector<std::string> fileNames = Face::LinAlg::Loader::listFiles(dataPath, "*.binz", Face::LinAlg::Loader::Filename);
int n = fileNames.size();
std::vector<int> ids = Face::Biometrics::BioDataProcessing::getIds(fileNames, "-");
std::vector<Mesh> meshes(n);
std::vector<double> times(n);
#pragma omp parallel for
for (int i = 0; i < n; i++)
{
//if (ids[i] >= 1002) break;
//if (ids[i] < 5000) continue;
Mesh m = Mesh::fromFile(dataPath + Poco::Path::separator() + fileNames[i]);
SurfaceProcessor::mdenoising(m, 0.01, 10, 0.01);
Poco::Timestamp before;
aligner.icpAlign(m, 50, FaceAligner::TemplateMatching);
times[i] = before.elapsed()/1000;
meshes[i] = m;
}
std::cout << "mean align time (ms) :" << (std::accumulate(times.begin(), times.end(), 0.0)/n) << std::endl;
evaluate(meshes, ids, pcaDepthmapPath);
}
示例7: waitDequeueNotification
Notification* TimedNotificationQueue::waitDequeueNotification(long milliseconds)
{
while (milliseconds >= 0)
{
_mutex.lock();
NfQueue::iterator it = _nfQueue.begin();
if (it != _nfQueue.end())
{
_mutex.unlock();
Poco::Timestamp now;
Timestamp::TimeDiff sleep = it->first - now;
if (sleep <= 0)
{
return dequeueOne(it).duplicate();
}
else if (sleep <= 1000*Timestamp::TimeDiff(milliseconds))
{
if (!wait(sleep))
{
return dequeueOne(it).duplicate();
}
else
{
milliseconds -= static_cast<long>((now.elapsed() + 999)/1000);
continue;
}
}
}
else
{
_mutex.unlock();
}
if (milliseconds > 0)
{
Poco::Timestamp now;
_nfAvailable.tryWait(milliseconds);
milliseconds -= static_cast<long>((now.elapsed() + 999)/1000);
}
else return 0;
}
return 0;
}
示例8: fillEvaluations
void MultiBiomertricsAutoTuner::fillEvaluations(const Input &sourceDatabaseTrainData,
const Input &targetDatabaseTrainData,
const Settings &settings, std::vector<Evaluation> &evaluations)
{
int allUnitsCount = settings.params.size();
Poco::Timestamp stamp;
#pragma omp parallel for
for (int i = 0; i < allUnitsCount; i++)
{
trainUnit(settings.params[i], sourceDatabaseTrainData, targetDatabaseTrainData, evaluations, i);
}
std::cout << "Training individual classifiers took " << (stamp.elapsed()/1000) << "ms";
}
示例9: faceDetect
void RealSenseSensorImpl::faceDetect(bool depthMask)
{
Poco::Int64 maskTime = 0;
Poco::Int64 detectTime = 0;
Poco::Timestamp now;
ImageGrayscale mask(grayscalePreview.clone());
if (depthMask) {
PXCCapture::Sample *sample = senseManager->QuerySample();
mask = RealSenseProcessor::depthMask(sample->depth, sample->color, projection, grayscalePreview);
//cv::imshow("Preview mask", mask);
}
maskTime = now.elapsed();
now.update();
cv::resize(mask, resizedPreview, cv::Size(320, 240), 0, 0, CV_INTER_NN);
roiPreview = resizedPreview(detectRoi);
tracker->detect(roiPreview);
detectTime = now.elapsed();
if (depthMask && tracker->isLastDetect()) {
cv::Rect faceRoi = toRealSizeRoi(tracker->getLastRegion());
mask = RealSenseProcessor::fillHoles(faceRoi, mask, grayscalePreview, 0.0);
//cv::imshow("grayscalePreview mask 2", mask);
}
//std::cout << std::dec << "Mask time: " << maskTime << "; Face detect time: " << detectTime << std::endl;
/*
if (Face::Settings::instance().debug()) {
if (tracker->isLastDetect()) {
cv::rectangle(colorPreview, toRealSizeRoi(tracker->getLastRegion()), 255);
}
//cv::imshow("detection", roiPreview);
}*/
}
示例10: newChild
virtual void newChild(const std::shared_ptr<Poco::Net::WebSocket> &socket) override
{
_childSockets.push_back(socket);
if (_childSockets.size() > NumToPrefork)
{
Poco::Timestamp::TimeDiff elapsed = _startTime.elapsed();
auto totalTime = (1000. * elapsed)/Poco::Timestamp::resolution();
Log::info() << "Launched " << _childSockets.size() << " in "
<< totalTime << Log::end;
size_t totalPSSKb = 0;
size_t totalDirtyKb = 0;
// Skip the last one as it's not completely initialized yet.
for (size_t i = 0; i < _childSockets.size() - 1; ++i)
{
Log::info() << "Getting memory of child #" << i + 1 << " of " << _childSockets.size() << Log::end;
if (!getMemory(_childSockets[i], totalPSSKb, totalDirtyKb))
{
exitTest(TestResult::TEST_FAILED);
return;
}
}
Log::info() << "Memory use total " << totalPSSKb << "k shared "
<< totalDirtyKb << "k dirty" << Log::end;
totalPSSKb /= _childSockets.size();
totalDirtyKb /= _childSockets.size();
Log::info() << "Memory use average " << totalPSSKb << "k shared "
<< totalDirtyKb << "k dirty" << Log::end;
Log::info() << "Launch time total " << totalTime << " ms" << Log::end;
totalTime /= _childSockets.size();
Log::info() << "Launch time average " << totalTime << " ms" << Log::end;
if (!_failure.empty())
{
Log::error("UnitPrefork failed due to: " + _failure);
exitTest(TestResult::TEST_FAILED);
}
else
{
Log::error("UnitPrefork success.");
exitTest(TestResult::TEST_OK);
}
}
}
示例11: newChild
virtual void newChild(WebSocketHandler &) override
{
_childSockets++;
LOG_INF("Unit-prefork: got new child, have " << _childSockets << " of " << NumToPrefork);
if (_childSockets >= NumToPrefork)
{
Poco::Timestamp::TimeDiff elapsed = _startTime.elapsed();
const double totalTime = (1000. * elapsed)/Poco::Timestamp::resolution();
LOG_INF("Launched " << _childSockets << " in " << totalTime);
std::cerr << "Launch time total " << totalTime << " ms" << std::endl;
std::cerr << "Launch time average " << (totalTime / _childSockets) << " ms" << std::endl;
exitTest(TestResult::Ok);
}
}
示例12: go
RealSenseSensor::State RealSenseSensorImpl::go()
{
try {
if (brightnessToSet != 0) {
Poco::Timestamp now;
check(device->SetColorBrightness(brightnessToSet), "Set color brightness failed");
printTimeIfBig(now.elapsed(), "setColorBrightnessTime");
brightnessToSet = 0;
}
switch (state) {
case RealSenseSensor::STATE_OFF:
// do nothing
break;
case RealSenseSensor::STATE_IDLE:
// Check for face presence every 5th frame
// Start positioning if face is present long enough
doIdle();
break;
case RealSenseSensor::STATE_POSITIONING:
// Navigate user to proper position
doPositioning();
break;
case RealSenseSensor::STATE_CAPTURING:
// Just convert current depth and color buffer to mesh
doCapturing();
break;
case RealSenseSensor::STATE_CAPTURING_DONE:
// do nothing
doCapturingDone();
break;
default:
break;
}
} catch (std::exception& e) {
std::cerr << "go() exception in state " << getState() << ": " << e.what() << std::endl;
}
return getState();
}
示例13: sendFontRendering
void ChildProcessSession::sendFontRendering(const char* /*buffer*/, int /*length*/, StringTokenizer& tokens)
{
std::string font, decodedFont;
int width, height;
unsigned char *pixmap;
if (tokens.count() < 2 ||
!getTokenString(tokens[1], "font", font))
{
sendTextFrame("error: cmd=renderfont kind=syntax");
return;
}
Poco::Mutex::ScopedLock lock(_mutex);
_loKitDocument->pClass->setView(_loKitDocument, _viewId);
URI::decode(font, decodedFont);
std::string response = "renderfont: " + Poco::cat(std::string(" "), tokens.begin() + 1, tokens.end()) + "\n";
std::vector<char> output;
output.resize(response.size());
std::memcpy(output.data(), response.data(), response.size());
Poco::Timestamp timestamp;
pixmap = _loKitDocument->pClass->renderFont(_loKitDocument, decodedFont.c_str(), &width, &height);
Log::trace("renderFont [" + font + "] rendered in " + std::to_string(timestamp.elapsed()/1000.) + "ms");
if (pixmap != nullptr)
{
if (!Util::encodePNGAndAppendToBuffer(pixmap, width, height, output, LOK_TILEMODE_RGBA))
{
sendTextFrame("error: cmd=renderfont kind=failure");
delete[] pixmap;
return;
}
delete[] pixmap;
}
sendBinaryFrame(output.data(), output.size());
}
示例14: flushCache
void Topology::flushCache() {
#ifdef DEBUG_TFC
StartupStore(TEXT("---flushCache() starts%s"),NEWLINE);
Poco::Timestamp starttick;;
#endif
switch (cache_mode) {
case 0: // Original
case 1: // Bounds array in memory
for (int i=0; i<shpfile.numshapes; i++) {
removeShape(i);
}
break;
case 2: // Shapes in memory
for (int i=0; i<shpfile.numshapes; i++) {
shpCache[i] = NULL;
}
break;
}//sw
shapes_visible_count = 0;
#ifdef DEBUG_TFC
StartupStore(TEXT(" flushCache() ends (%dms)%s"),Poco::Timespan(starttick.elapsed()).totalMilliseconds(),NEWLINE);
#endif
}
示例15: sleepImpl
void ThreadImpl::sleepImpl(long milliseconds)
{
Poco::Timespan remainingTime(1000*Poco::Timespan::TimeDiff(milliseconds));
int rc;
do
{
struct timespec ts;
ts.tv_sec = (long) remainingTime.totalSeconds();
ts.tv_nsec = (long) remainingTime.useconds()*1000;
Poco::Timestamp start;
rc = ::nanosleep(&ts, 0);
if (rc < 0 && errno == EINTR)
{
Poco::Timestamp end;
Poco::Timespan waited = start.elapsed();
if (waited < remainingTime)
remainingTime -= waited;
else
remainingTime = 0;
}
}
while (remainingTime > 0 && rc < 0 && errno == EINTR);
if (rc < 0 && remainingTime > 0) throw Poco::SystemException("Thread::sleep(): nanosleep() failed");
}