本文整理汇总了C++中time_duration::total_milliseconds方法的典型用法代码示例。如果您正苦于以下问题:C++ time_duration::total_milliseconds方法的具体用法?C++ time_duration::total_milliseconds怎么用?C++ time_duration::total_milliseconds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类time_duration
的用法示例。
在下文中一共展示了time_duration::total_milliseconds方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: convertSqlDateToMilliSecs
uint64_t convertSqlDateToMilliSecs(const std::string& dateString)
{
using namespace boost::posix_time;
ptime epoch = time_from_string("1970-01-01 00:00:00.000");
ptime other;
if (dateString.find(" ") == std::string::npos)
other = time_from_string(std::string(dateString + " 00:00:00.000"));
else
other = time_from_string(dateString);
time_duration const diff = other - epoch;
return diff.total_milliseconds();
}
示例2: performsSpeedFilesTest
void FluteLibTest::performsSpeedFilesTest(int aFileSize, int aKBitRates)
{
TemporaryFile myTemporaryFile(aFileSize);
ptime myStart(microsec_clock::local_time());
unsigned long long mySessionSize =
this->performsFileSend(myTemporaryFile, aKBitRates);
ptime myEnd(microsec_clock::local_time());
const time_duration myRealDuration = myEnd - myStart;
const double myRealSecDuration = myRealDuration.total_milliseconds()/1000.0;
const double mySecDuration = double(mySessionSize*8)/double(aKBitRates*1024);
const double myError = fabs(mySecDuration-myRealSecDuration)/mySecDuration;
CPPUNIT_ASSERT(myError<0.05);
}
示例3: normv
//.........这里部分代码省略.........
for(;;) {
hm = orghm->GetLevel(-level);
w=hm->w-1;
GLint maxw;
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxw);
if (w > maxw) level ++;
else break;
}
shadowLevelDif=0;
Heightmap *shadowhm = orghm->GetLevel(-(level+shadowLevelDif));
int shadowScale=1<<shadowLevelDif;
int shadowW=shadowhm->w-1;
assert (w/shadowW == shadowScale);
//float org2c = w/float(orghm->w-1);
//float c2org = (float)(orghm->w-1)/w;
float *centerhm = new float[w*w];
Vector3 *shading = new Vector3[w*w];
for (int y=0;y<w;y++)
for (int x=0;x<w;x++) {
centerhm[y*w+x] =/* hm->scale * */ 0.25f * ( (int)hm->at(x,y)+ (int)hm->at(x+1,y)+ (int)hm->at(x,y+1) + (int)hm->at(x+1,y+1) ); //+ hm->offset;
shading[y*w+x] = li->ambient;
}
uchar *lightMap = new uchar[shadowW*shadowW];
for (std::vector<StaticLight>::const_iterator l=li->staticLights.begin();l!=li->staticLights.end();++l)
{
float lightx;
float lighty;
if (l->directional) {
lightx = l->position.x;
lighty = l->position.y;
} else {
lightx = (int)(l->position.x / shadowhm->squareSize);
lighty = (int)(l->position.z / shadowhm->squareSize);
}
CalculateShadows(lightMap, shadowW, lightx, lighty,
l->position.y, centerhm, w, shadowScale, l->directional);
for (int y=0;y<w;y++)
{
for (int x=0;x<w;x++)
{
if (!lightMap[(y*shadowW+x)/shadowScale])
continue;
Vector3 wp;
if (l->directional)
wp = l->position;
else
wp = l->position - Vector3((x+0.5f)*hm->squareSize,centerhm[y*w+x],(y+0.5f)*hm->squareSize);
uchar* normal = hm->GetNormal (x,y);
Vector3 normv((2 * (int)normal[0] - 256)/255.0f, (2 * (int)normal[1] - 256)/255.0f, (2 * (int)normal[2] - 256)/255.0f);
wp.ANormalize();
float dot = wp.dot(normv);
if(dot < 0.0f) dot = 0.0f;
if(dot > 1.0f) dot = 1.0f;
dot *= lightMap[(y*shadowW+x)/shadowScale]*(1.0f/255.0f);
shading[y*w+x] += l->color * dot;
}
}
}
delete[] lightMap;
glGenTextures(1,&shadingTex);
glBindTexture (GL_TEXTURE_2D, shadingTex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
uchar *shadingTexData=new uchar[w*w*4];
for(int y=0;y<w;y++) {
for (int x=0;x<w;x++) {
shadingTexData[(y*w+x)*4+0] = (uchar)(min(1.0f, shading[y*w+x].x) * 255);
shadingTexData[(y*w+x)*4+1] = (uchar)(min(1.0f, shading[y*w+x].y) * 255);
shadingTexData[(y*w+x)*4+2] = (uchar)(min(1.0f, shading[y*w+x].z) * 255);
shadingTexData[(y*w+x)*4+3] = CReadMap::EncodeHeight(centerhm[w*y+x]);
}
}
SaveImage ("lightmap.png", 4, IL_UNSIGNED_BYTE, w,w, shadingTexData);
glBuildMipmaps(GL_TEXTURE_2D, 4, w,w, GL_RGBA, GL_UNSIGNED_BYTE, shadingTexData);
delete[] shadingTexData;
id = shadingTex;
delete[] shading;
delete[] centerhm;
const time_duration numTicks = microsec_clock::local_time() - startTicks;
d_trace ("Lightmap generation: %2.3f seconds\n", numTicks.total_milliseconds() * 0.001f);
}