本文整理汇总了C++中duration类的典型用法代码示例。如果您正苦于以下问题:C++ duration类的具体用法?C++ duration怎么用?C++ duration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了duration类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: policyProgressbar
inline std::string policyProgressbar(unsigned const nTotal, unsigned const current = 0){
using namespace std::chrono;
static unsigned maxNTotal = 0;
static unsigned part = 0;
static unsigned tic = 0;
static time_point<steady_clock> startTime;
if(part==0){ startTime = steady_clock::now(); } // get the starting time on the very first call
std::stringstream ss;
auto const now = steady_clock::now();
maxNTotal = std::max(maxNTotal, nTotal);
part = current ? current : part+1;
//limit the update intervall (not faster than every 35ms. This would be madness.)
duration<float> const timeSpent = now - startTime;
if(timeSpent.count() > 0.035f*tic || part == maxNTotal){
++tic;
std::string frame;
unsigned height;
// use all policies to compose a single frame and save its height
std::tie(frame, height) = iteratePolicies<PolicyList...>(part, maxNTotal);
ss << frame;
ss << std::flush;
//move the cursor back to the beginning
if(part!=maxNTotal) ss << "\033[" << height << "A\r";
else ss << "\n";
}
return ss.str();
}
开发者ID:eucall-software,项目名称:DSP,代码行数:35,代码来源:policyProgressbar.hpp
示例2: do_iteration
iteration_stats do_iteration()
{
using namespace boost::chrono;
using boost::make_tuple;
// Zero the counters (to be set during advance() by our slot)
tree_time_ = particle_time_ = 0.0;
particles_visited_ = pparticles_visited_ = 0;
// Get the number of acceleration evals before advancing
const int init_neval = particle_pusher_.num_acceleval();
// Get the current time
const steady_clock::time_point start_time = steady_clock::now();
// Advance the system
particle_pusher_.advance();
// Determine how much time has elapsed
const duration<double> net_push_time = steady_clock::now() - start_time;
// Generate the iteration statistics; see accel_timings_slot
return make_tuple(tree_time_,
particle_time_,
net_push_time.count() - tree_time_ - particle_time_,
particles_visited_,
pparticles_visited_,
particle_pusher_.num_acceleval() - init_neval);
}
开发者ID:FreddieWitherden,项目名称:teatree,代码行数:29,代码来源:impl.hpp
示例3: string
std::string mir::logging::input_timestamp(nanoseconds when)
{
// Input events use CLOCK_MONOTONIC, and so we must...
duration<double, std::milli> const age = steady_clock::now().time_since_epoch() - when;
char str[64];
snprintf(str, sizeof str, "%lld (%.6fms ago)",
static_cast<long long>(when.count()),age.count());
return std::string(str);
}
开发者ID:ubuntu-touch-leo,项目名称:mir,代码行数:11,代码来源:input_timestamp.cpp
示例4: main
int main(int argc, char * argv[])
{
if (argc != 2)
{
cerr << "Formato " << argv[0] << " <num_elem>" << endl;
return -1;
}
int n = atoi(argv[1]);
int * T = new int[n];
assert(T);
srandom(time(0));
for (int i = 0; i < n; i++)
{
T[i] = random();
};
// escribe_vector(T, n);
tantes = high_resolution_clock::now();
heapsort(T, n);
tdespues = high_resolution_clock::now();
transcurrido = duration_cast<duration<double>>(tdespues - tantes);
cout << n << " "<< transcurrido.count() << endl;
// escribe_vector(T, n);
delete [] T;
return 0;
};
开发者ID:josearcosaneas,项目名称:Algoritmica-1,代码行数:35,代码来源:heapsort.cpp
示例5: main
/*
*
* @brief Funcion Principal:
*
*/
int main(int argc, char const *argv[]){
if (argc != 4){
cerr << "Formato " << argv[0] << "<ruta_del_archivo_de_entrada> <num_elem> <num_vect>" << endl;
return -1;
}
int tam_vectores = atoi(argv[2]); //Tamaño vectores
int num_vectores = atoi(argv[3]); //Número vectores
int num = 0;
string ruta=argv[1];
ifstream archivo(ruta.c_str());
// cargamos todos los vectores en una matriz de tipo vector<vector>
matrix vectorAux(num_vectores,tam_vectores);
matrix vectorT (num_vectores, tam_vectores);
vector< vector<int> > vectorRes;
for(int i = 0; i < num_vectores; i++){
for (int j = 0 ; j < tam_vectores; j++){
archivo >> num;
vectorT.datos[i][j] = num;
}
}
tantes = high_resolution_clock::now();
vectorAux = mergeKvectors(vectorT);
tdespues = high_resolution_clock::now();
transcurrido = duration_cast<duration<double>>(tdespues - tantes);
cout << tam_vectores << " "<< transcurrido.count() << endl;
return 0;
}
开发者ID:pacocp,项目名称:GII-UGR-Algoritmica,代码行数:38,代码来源:RecursivoV1.cpp
示例6: to_boost_duration
boost::posix_time::time_duration const
to_boost_duration(
duration<
Rep,
Period
> const &duration_
)
{
BOOST_STATIC_ASSERT(
Period::num == 1
);
return
boost::date_time::subsecond_duration<
boost::posix_time::time_duration,
Period::den
>(
duration_.count()
);
}
开发者ID:pmiddend,项目名称:sgedoxy,代码行数:20,代码来源:to_boost_duration.hpp
示例7:
inline duration<Rep1, Period1> operator % (duration<Rep1, Period1> const & lhs
, duration<Rep2, Period2> const & rhs)
{
return lhs.count() % rhs.count();
}
开发者ID:semenovf,项目名称:pfs,代码行数:5,代码来源:chrono_custom.hpp
示例8: printHelpText
int Raw2xBase::run()
{
if (cmdLine.getArgCount() == 0)
{
std::cout << "Not enough arguments!\n";
printHelpText();
return 0;
}
if (cmdLine.hasFlag("h") || cmdLine.hasFlag("help"))
{
printHelpText();
return 0;
}
std::string inFileName, outFileName;
// input_file + output_file
if (cmdLine.getArgCount() >= 2 && cmdLine.getArg(1)[0] != '-') // If arg[1] is not a flag...
{
inFileName = cmdLine.getArg(0);
outFileName = cmdLine.getArg(1);
}
else // Just input_file
{
inFileName = cmdLine.getArg(0);
outFileName.clear();
}
// Replace '.raw' extension of source file with the proper extension
// and use it for the output if no explicit filename was provided.
if (outFileName.empty())
{
outFileName = utils::filesys::removeFilenameExtension(inFileName) + outputFileExt;
}
if (verbose)
{
std::cout << "In file..: " << inFileName << "\n";
std::cout << "Out file.: " << outFileName << "\n";
std::cout << "Options..: " << cmdLine.getFlagsString() << "\n";
}
// We optionally measure execution time.
using namespace std::chrono;
system_clock::time_point t0, t1;
if (timings)
{
t0 = system_clock::now();
}
// Try to open the input file. This might result in an exception.
siege::RawImage rawImage(inFileName);
if (rawImage.getSurfaceCount() > 1 && mipmaps)
{
std::string surfName;
const int surfCount = rawImage.getSurfaceCount();
for (int s = 0; s < surfCount; ++s)
{
surfName = utils::filesys::removeFilenameExtension(outFileName) + "_" + std::to_string(s) + outputFileExt;
writeImageSurf(rawImage, s, surfName, swizzle);
}
}
else // Single image (mipmap 0):
{
writeImageSurf(rawImage, 0, outFileName, swizzle);
}
if (timings)
{
t1 = system_clock::now();
const duration<double> elapsedSeconds(t1 - t0);
const auto endTime = system_clock::to_time_t(t1);
#ifdef _MSC_VER
char timeStr[256];
ctime_s(timeStr, sizeof(timeStr), &endTime);
#else // _MSC_VER
const char * const timeStr = std::ctime(&endTime);
#endif // _MSC_VER
std::cout << "Finished execution on " << timeStr
<< "Elapsed time: " << elapsedSeconds.count() << "s\n";
}
return 0;
}
开发者ID:mewbak,项目名称:reverse-engineering-dungeon-siege,代码行数:91,代码来源:raw2x_base.cpp
示例9: f
void f(duration<double> d, double res) // accept floating point seconds
{
// d.count() == 3.e-6 when passed microseconds(3)
BOOST_ASSERT(d.count()==res);
}
开发者ID:Kirija,项目名称:XPIR,代码行数:5,代码来源:test_duration.cpp
示例10: printFormatted
// we've made this function private as it doesn't need to be accessed outside this
// functor. It contains implemenatation details.
void printFormatted( duration<double> elapsed, const string &string )
{
cout << "[LOG ENTRY]: " << elapsed.count() << "s, Entry: " << string << endl;
}
开发者ID:itpresidents,项目名称:CreativeCoding,代码行数:6,代码来源:main.cpp
示例11: timeout_t
timeout_t(duration interval, Func&& callback)
: callback(std::forward<Func>(callback)),
id{::SDL_AddTimer(interval.count(), run_callback, this)} {
SDLXX_CHECK(id != 0);
}
开发者ID:tcbrindle,项目名称:sdlxx,代码行数:5,代码来源:timer.hpp
示例12: duration_cast
To duration_cast(duration const& d) {
rational dstr(To::period::num, To::period::den);
rational tr = d.ratio() / dstr;
return To(tr.numerator() / tr.denominator());
}
开发者ID:michail-peterlis,项目名称:prosto,代码行数:6,代码来源:duration.hpp
示例13: segmentImage
std::vector<cv::Mat> HierClassifier::classify(cv::Mat image,
cv::Mat terrain,
cv::Mat segmentation,
cv::Mat maskIgnore,
int entryWeightThreshold)
{
Mat regionsOnImage;
if(segmentation.empty()){
regionsOnImage = segmentImage(image);
}
else{
regionsOnImage = segmentation;
}
vector<Entry> entries = extractEntries(image,
terrain,
regionsOnImage,
maskIgnore,
entryWeightThreshold);
using namespace std::chrono;
high_resolution_clock::time_point start = high_resolution_clock::now();
high_resolution_clock::time_point end;
//ofstream log("descriptors");
//for(int e = 0; e < entries.size(); e++){
// log << entries[e].descriptor << endl;
//}
map<int, int> imageIdToEntry;
for(int e = 0; e < entries.size(); e++){
imageIdToEntry[entries[e].imageId] = e;
}
Mat result(entries.size(), numLabels, CV_32FC1, Scalar(0));
for(int c = 0; c < classifiers.size(); c++){
//cout << "Classifing using classifier " << c << endl;
for(int e = 0; e < entries.size(); e++){
//cout << "classInfo.descBeg = " << classifiersInfo[c].descBeg << ", descEnd = " << classifiersInfo[c].descEnd << endl;
//cout << "descriptor.numCols = " << entries[e].descriptor.cols << endl;
Mat desc = entries[e].descriptor.colRange(
classifiersInfo[c].descBeg,
classifiersInfo[c].descEnd);
//cout << "result, entry " << e << ", " << weights[c]*classifiers[c]->classify(desc) << endl;
result.row(e) = result.row(e) + weights[c]*classifiers[c]->classify(desc);
}
}
vector<Mat> ret;
ret.resize(numLabels);
for(int l = 0; l < numLabels; l++){
ret[l] = Mat(image.rows, image.cols, CV_32FC1, Scalar(-2));
}
for(int l = 0; l < numLabels; l++){
for(int r = 0; r < image.rows; r++){
for(int c = 0; c < image.cols; c++){
if(imageIdToEntry.count(regionsOnImage.at<int>(r, c)) > 0){
ret[l].at<float>(r, c) = result.at<float>(imageIdToEntry[regionsOnImage.at<int>(r, c)], l);
}
}
}
}
end = high_resolution_clock::now();
static duration<double> compTime = duration<double>::zero();
static int times = 0;
compTime += duration_cast<duration<double> >(end - start);
times++;
if(debugLevel >= 1){
cout << "Classify Times: " << times << endl;
cout << "Classify Average computing time: " << compTime.count()/times << endl;
}
return ret;
}
开发者ID:jakub-tomczak,项目名称:TAPAS,代码行数:75,代码来源:HierClassifier.cpp
示例14: physics_function
void physics_function(duration<double> d)
{
std::cout << "d = " << d.count() << '\n';
}
开发者ID:Kirija,项目名称:XPIR,代码行数:4,代码来源:miscellaneous.cpp
示例15: timeout
void reactor::timeout(duration timeout) {
if (timeout == duration::FOREVER || timeout.milliseconds() > PN_MILLIS_MAX)
pn_reactor_set_timeout(pn_object(), PN_MILLIS_MAX);
else
pn_reactor_set_timeout(pn_object(), timeout.milliseconds());
}
开发者ID:irods,项目名称:qpid-proton,代码行数:6,代码来源:reactor.cpp
示例16: f
constexpr int
f (duration < 0 > d, duration < 0 > )
{
return d.count ();
}
开发者ID:0day-ci,项目名称:gcc,代码行数:5,代码来源:constexpr-non-const-arg2.C
示例17: Mat
//.........这里部分代码省略.........
//normalize(meanLaser, meanLaser);
//cout << "covarLaser = " << covarLaser << endl;
//cout << "meanLaser = " << meanLaser << endl;
//cout << "Entry " << ret.size() << endl;
//cout << "histHS = " << histogramHS << endl;
//cout << "histV = " << histogramV << endl;
//cout << "covarHSV = " << covarHSV << endl;
//cout << "meanHSV = " << meanHSV << endl;
Mat kurtLaser(1, 2, CV_32FC1);
Mat tmpVal;
valuesTer.rowRange(4, 6).copyTo(tmpVal);
//cout << "tmpVal = " << tmpVal << endl;
//cout << "mean(0) = " << meanLaser.at<float>(0) << ", mean(1) = " << meanLaser.at<float>(1) << endl;
//cout << "stdDev^4(0) = " << pow(covarLaser.at<float>(0), 2) << ", stdDev^4(3) = " << pow(covarLaser.at<float>(3), 2) << endl;
tmpVal.rowRange(0, 1) -= meanLaser.at<float>(0);
tmpVal.rowRange(1, 2) -= meanLaser.at<float>(1);
pow(tmpVal, 4, tmpVal);
kurtLaser.at<float>(0) = sum(tmpVal.rowRange(0, 1))(0);
if(tmpVal.cols * pow(covarLaser.at<float>(0), 2) != 0){
kurtLaser.at<float>(0) = kurtLaser.at<float>(0) / (tmpVal.cols * pow(covarLaser.at<float>(0), 2)) - 3;
}
kurtLaser.at<float>(1) = sum(tmpVal.rowRange(1, 2))(0);
if(tmpVal.cols * pow(covarLaser.at<float>(3), 2) != 0){
kurtLaser.at<float>(1) = kurtLaser.at<float>(1) / (tmpVal.cols * pow(covarLaser.at<float>(3), 2)) - 3;
}
Mat histogramDI;
int channelsDI[] = {0, 1};
float rangeD[] = {1500, 2500};
float rangeI[] = {1800, 4000};
const float* rangesDI[] = {rangeD, rangeI};
int sizeDI[] = {histDLen, histILen};
Mat valHistD = valuesTer.rowRange(4, 5);
Mat valHistI = valuesTer.rowRange(5, 6);
Mat valuesHistDI[] = {valHistD, valHistI};
calcHist(valuesHistDI, 2, channelsDI, Mat(), histogramDI, 2, sizeDI, rangesDI);
histogramDI = histogramDI.reshape(0, 1);
normalize(histogramDI, histogramDI);
//cout << "histogramDI = " << histogramDI << endl;
Entry tmp;
tmp.imageId = pixels[begIm].imageId;
tmp.weight = (endIm - begIm)/* + (endTer - begTer)*/;
tmp.descriptor = Mat(1, histHLen*histSLen +
histVLen +
meanHSVLen +
covarHSVLen +
histDLen*histILen +
meanLaserLen +
covarLaserLen,
CV_32FC1);
int begCol = 0;
histogramHS.copyTo(tmp.descriptor.colRange(begCol, begCol + histHLen*histSLen));
begCol += histHLen*histSLen;
histogramV.copyTo(tmp.descriptor.colRange(begCol, begCol + histVLen));
begCol += histVLen;
meanHSV.copyTo(tmp.descriptor.colRange(begCol, begCol + meanHSVLen));
begCol += meanHSVLen;
covarHSV.copyTo(tmp.descriptor.colRange(begCol, begCol + covarHSVLen));
begCol += covarHSVLen;
histogramDI.copyTo(tmp.descriptor.colRange(begCol, begCol + histDLen*histILen));
begCol += histDLen*histILen;
meanLaser.copyTo(tmp.descriptor.colRange(begCol, begCol + meanLaserLen));
begCol += meanLaserLen;
covarLaser.copyTo(tmp.descriptor.colRange(begCol, begCol + covarLaserLen));
begCol += covarLaserLen;
//kurtLaser.copyTo(tmp.descriptor.colRange(begCol, begCol + kurtLaserLen));
//begCol += kurtLaserLen;
//cout << "descriptor = " << tmp.descriptor << endl;
if(endIm - begIm > entryWeightThreshold){
ret.push_back(tmp);
}
}
}
static duration<double> sortingTime = duration<double>::zero();
static duration<double> compTime = duration<double>::zero();
static duration<double> wholeTime = duration<double>::zero();
static int times = 0;
high_resolution_clock::time_point endComp = high_resolution_clock::now();
sortingTime += duration_cast<duration<double> >(endSorting - start);
compTime += duration_cast<duration<double> >(endComp - endSorting);
wholeTime += duration_cast<duration<double> >(endComp - start);
times++;
if(debugLevel >= 1){
cout << "Times: " << times << endl;
cout << "Extract Average sorting time: " << sortingTime.count()/times << endl;
cout << "Extract Average computing time: " << compTime.count()/times << endl;
cout << "Extract Average whole time: " << wholeTime.count()/times << endl;
}
return ret;
}
开发者ID:jakub-tomczak,项目名称:TAPAS,代码行数:101,代码来源:HierClassifier.cpp
示例18: duration
duration (duration<Rep2, Period2> const & d)
: _r(d.count())
{}
开发者ID:semenovf,项目名称:pfs,代码行数:3,代码来源:chrono_custom.hpp
示例19: pn_message_set_ttl
void message::ttl(duration d) { pn_message_set_ttl(pn_msg(), d.milliseconds()); }
开发者ID:ChugR,项目名称:qpid-proton,代码行数:1,代码来源:message.cpp
示例20: delay
/*!
Wait a specfied time interval before returning.
@note The standard library provides `std::this_thread::sleep_for()` and
`std::this_thread::sleep_until()` which may be preferred to this function.
*/
inline void delay(duration interval) { ::SDL_Delay(interval.count()); }
开发者ID:tcbrindle,项目名称:sdlxx,代码行数:7,代码来源:timer.hpp
注:本文中的duration类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论