本文整理汇总了C++中end_time函数的典型用法代码示例。如果您正苦于以下问题:C++ end_time函数的具体用法?C++ end_time怎么用?C++ end_time使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了end_time函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _receive_msg
/*
* the main method
* receives a Flow message and prints out its associated information
* If the message belongs to another class, an exception is thrown.
*/
virtual void _receive_msg(std::shared_ptr<const Msg>&& m, int /* index */)
{
if ( m->type() == MSG_ID(Flow) )
{
auto flow = static_cast<const Flow *>(m.get());
std::stringstream ss;
const FlowKey& fk = flow->key();
int duration = flow->end_time() - flow->start_time();
ss<<"packets="<<flow->packets() << ",";
ss<<"bytes="<<flow->bytes() << ",";
ss<<"start="<<flow->start_time() << ",";
ss<<"end="<<flow->end_time() << ",";
ss<<"duration.us="<<duration<< ",";
ss<<"source.ip4="<<ip_to_string(fk.src_ip4)<< ",";
ss<<"source.port="<<fk.src_port<< ",";
ss<<"destination.ip4="<<ip_to_string(fk.dst_ip4)<< ",";
ss<<"destination.port="<<fk.dst_port;
/*
ss<<"Flow of "<< flow->packets() << " packets and "<<flow->bytes()<<" bytes begin at "<<flow->start_time()<<" end at "<<flow->end_time()<< "duration (ms.) "<<duration <<std::endl;
ss<<"SRC IP "<<ip_to_string(fk.src_ip4)<<" SRC port "<<fk.src_port<<std::endl;
ss<<"DST IP "<<ip_to_string(fk.dst_ip4)<<" DST port "<<fk.dst_port<<std::endl;
//ss<<"protocol "<<fk.proto<<std::endl;
*/
blocklog(ss.str(),log_info);
}
else
{
throw std::runtime_error("Flowprinter: wrong message type");
}
}
示例2: main
int main() {
int i;
double libc, fire;
struct firedns_state state, *s = &state;
firedns_init(s);
firedns_add_servers_from_resolv_conf(s);
printf("Testing %d firedns_resolveip4list(\"%s\"):\n",TESTS,TEST_HOST);
start_time();
for (i = 0; i < TESTS; i++)
firedns_resolveip4list(s, TEST_HOST);
fire = end_time();
printf("Testing %d gethostbyname(\"%s\"):\n",TESTS,TEST_HOST);
start_time();
for (i = 0; i < TESTS; i++)
gethostbyname(TEST_HOST);
libc = end_time();
if (libc > fire)
printf("Speedup: %d%%\n",(int) (((libc - fire) / libc) * 100.0));
else
printf("Slowdown: %d%%\n",(int) (((fire - libc) / libc) * 100.0));
return 0;
}
示例3: prolongate
void prolongate( int level ) {
int i,j;
const int prolongation_vars[1] = { VAR_POTENTIAL };
int icell;
int num_level_cells;
int *level_cells;
cart_assert( level >= min_level+1 );
start_time( WORK_TIMER );
select_level( level-1, CELL_TYPE_LOCAL | CELL_TYPE_REFINED, &num_level_cells, &level_cells );
#pragma omp parallel for default(none), private(i,icell,j), shared(num_level_cells,level_cells,cell_vars,cell_child_oct)
for ( i = 0; i < num_level_cells; i++ ) {
icell = level_cells[i];
for ( j = 0; j < num_children; j++ ) {
cell_potential( cell_child(icell,j) ) = cell_interpolate( icell, j, VAR_POTENTIAL );
}
}
cart_free( level_cells );
end_time( WORK_TIMER );
/* update buffers */
start_time( PROLONGATE_UPDATE_TIMER );
update_buffer_level( level, prolongation_vars, 1 );
end_time( PROLONGATE_UPDATE_TIMER );
}
示例4: compute_accelerations_particles
void compute_accelerations_particles( int level ) {
int i, j;
double a2half;
const int accel_vars[nDim] = { VAR_ACCEL, VAR_ACCEL+1, VAR_ACCEL+2 };
int neighbors[num_neighbors];
int L1, R1;
double phi_l, phi_r;
int icell;
int num_level_cells;
int *level_cells;
start_time( GRAVITY_TIMER );
start_time( PARTICLE_ACCEL_TIMER );
start_time( WORK_TIMER );
#ifdef COSMOLOGY
a2half = -0.5*abox[level]*abox[level]*cell_size_inverse[level];
#else
a2half = -0.5 * cell_size_inverse[level];
#endif
select_level( level, CELL_TYPE_LOCAL, &num_level_cells, &level_cells );
#pragma omp parallel for default(none), private(icell,j,neighbors,L1,R1,phi_l,phi_r), shared(num_level_cells,level_cells,level,cell_vars,a2half)
for ( i = 0; i < num_level_cells; i++ ) {
icell = level_cells[i];
cell_all_neighbors( icell, neighbors );
for ( j = 0; j < nDim; j++ ) {
L1 = neighbors[2*j];
R1 = neighbors[2*j+1];
if ( cell_level(L1) < level ) {
phi_l = 0.8*cell_potential(L1) + 0.2*cell_potential(icell);
} else {
phi_l = cell_potential(L1);
}
if ( cell_level(R1) < level ) {
phi_r = 0.8*cell_potential(R1)+0.2*cell_potential(icell);
} else {
phi_r = cell_potential(R1);
}
cell_accel( icell, j ) = (float)(a2half * ( phi_r - phi_l ) );
}
}
cart_free( level_cells );
end_time( WORK_TIMER );
/* update accelerations */
start_time( PARTICLE_ACCEL_UPDATE_TIMER );
update_buffer_level( level, accel_vars, nDim );
end_time( PARTICLE_ACCEL_UPDATE_TIMER );
end_time( PARTICLE_ACCEL_TIMER );
end_time( GRAVITY_TIMER );
}
示例5: free_matrix_indices
void DiscreteProblem::create_matrix()
{
// remove any previous matrix
free_matrix_indices();
free_matrix_values();
// calculate the total number of DOFs
ndofs = 0;
for (int i = 0; i < neq; i++)
ndofs += spaces[i]->get_num_dofs();
if (!quiet) verbose("Ndofs: %d", ndofs);
if (!ndofs) return;
// get row and column indices of nonzero matrix elements
Page** pages = new Page*[ndofs];
memset(pages, 0, sizeof(Page*) * ndofs);
if (!quiet) { verbose("Calculating matrix sparse structure..."); begin_time(); }
precalculate_sparse_structure(pages);
// initialize the arrays Ap and Ai
Ap = (int*) malloc(sizeof(int) * (ndofs+1));
int aisize = get_num_indices(pages, ndofs);
Ai = (int*) malloc(sizeof(int) * aisize);
if (Ai == NULL) error("Out of memory. Could not allocate the array Ai.");
// sort the indices and remove duplicities, insert into Ai
int i, pos = 0, num;
for (i = 0; i < ndofs; i++)
{
Ap[i] = pos;
pos += sort_and_store_indices(pages[i], Ai + pos, Ai + aisize);
}
Ap[i] = pos;
if (!quiet) verbose(" Nonzeros: %d\n Total matrix size: %0.1lf MB\n (time: %g sec)",
pos, (double) get_matrix_size() / (1024*1024), end_time());
delete [] pages;
// shrink Ai to the actual size
int* oldAi = Ai;
Ai = (int*) realloc(Ai, sizeof(int) * pos);
if (oldAi != Ai) warn("Realloc moved Ai when shrinking."); // this should not happen
// UMFPACK: perform symbolic analysis of the matrix
if (!quiet) { verbose("Performing UMFPACK symbolic analysis..."); begin_time(); }
int status = umfpack_symbolic(ndofs, ndofs, Ap, Ai, NULL, &Symbolic, NULL, NULL);
if (status != UMFPACK_OK) umfpack_status(status);
if (!quiet) verbose(" (time: %g sec)", end_time());
equi = (double*) malloc(sizeof(double) * ndofs);
if (equi == NULL) error("Out of memory. Error allocating the equilibration vector.");
for (int i = 0; i < ndofs; i++)
equi[i] = 1.0;
is_equi = false;
}
示例6: rtOtvetSingleSourceEddingtonTensor
void rtOtvetSingleSourceEddingtonTensor(int level)
{
int i, j, l, index, cell;
int num_level_cells, *level_cells;
double eps1, eps2, dr2, pos[nDim];
start_time(WORK_TIMER);
eps1 = 0.01*cell_size[rtSingleSourceLevel]*cell_size[rtSingleSourceLevel];
eps2 = 9*cell_size[rtSingleSourceLevel]*cell_size[rtSingleSourceLevel];
select_level(level,CELL_TYPE_LOCAL,&num_level_cells,&level_cells);
#pragma omp parallel for default(none), private(index,cell,pos,dr2,i,j,l), shared(level,num_level_cells,level_cells,rtSingleSourceValue,rtSingleSourcePos,eps1,eps2,cell_vars)
for(index=0; index<num_level_cells; index++)
{
cell = level_cells[index];
cell_center_position(cell,pos);
dr2 = eps1;
for(i=0; i<nDim; i++)
{
pos[i] -= rtSingleSourcePos[i];
if(pos[i] > 0.5*num_grid) pos[i] -= num_grid;
if(pos[i] < -0.5*num_grid) pos[i] += num_grid;
dr2 += pos[i]*pos[i];
}
cell_var(cell,RT_VAR_OT_FIELD) = rtSingleSourceValue/(4*M_PI*dr2);
dr2 += nDim*eps2;
for(l=j=0; j<nDim; j++)
{
for(i=0; i<j; i++)
{
cell_var(cell,rt_et_offset+l++) = pos[i]*pos[j]/dr2;
}
cell_var(cell,rt_et_offset+l++) = (eps2+pos[j]*pos[j])/dr2;
}
}
cart_free(level_cells);
end_time(WORK_TIMER);
start_time(RT_SINGLE_SOURCE_UPDATE_TIMER);
update_buffer_level(level,rtOtvetETVars,rtNumOtvetETVars);
end_time(RT_SINGLE_SOURCE_UPDATE_TIMER);
}
示例7: readFile
int readFile(int use, int dsize)
{
int p;
if (largeFile) start_time();
handle = open(testFile, O_RDONLY, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
if (handle == -1)
{
sprintf(resultchars, " Cannot open %s for reading\n", testFile);
return 0;
}
for (p=0; p<use; p++)
{
if (read(handle, dataIn, dsize) == -1)
{
sprintf(resultchars," Error reading file %s block %d\n", testFile, p+1);
return 0;
}
}
close(handle);
if (largeFile) end_time();
return 1;
}
示例8: _on_event
Note<Time>::Note(const Note<Time>& copy)
: _on_event(copy._on_event, true)
, _off_event(copy._off_event, true)
{
set_id (copy.id());
assert(_on_event.buffer());
assert(_off_event.buffer());
/*
assert(copy._on_event.size == 3);
_on_event.buffer = _on_event_buffer;
memcpy(_on_event_buffer, copy._on_event_buffer, 3);
assert(copy._off_event.size == 3);
_off_event.buffer = _off_event_buffer;
memcpy(_off_event_buffer, copy._off_event_buffer, 3);
*/
assert(time() == copy.time());
assert(end_time() == copy.end_time());
assert(length() == copy.length());
assert(note() == copy.note());
assert(velocity() == copy.velocity());
assert(_on_event.channel() == _off_event.channel());
assert(channel() == copy.channel());
}
示例9: writeFile
int writeFile(int use, int dsize)
{
int p;
if (largeFile) start_time();
if (useCache)
{
handle = open(testFile, O_WRONLY | O_CREAT | O_TRUNC,
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
}
else
{
handle = open(testFile, O_WRONLY | O_CREAT | O_TRUNC | O_DIRECT | O_SYNC,
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP| S_IROTH | S_IWOTH); // O_DIRECT | O_SYNC
}
if (handle == -1)
{
sprintf(resultchars, " Cannot open %s for writing\n", testFile);
return 0;
}
for (p=0; p<use; p++)
{
if (write(handle, dataOut, dsize) != dsize )
{
sprintf(resultchars," Error writing file %s block %d\n", testFile, p+1);
return 0;
}
}
close(handle);
if (largeFile) end_time();
return 1;
}
示例10: main
int main(int argc, char* argv[])
{
// Load the mesh
Mesh mesh;
H2DReader mloader;
mloader.load("domain.mesh", &mesh);
for (int i=0; i < INIT_REF_NUM; i++) mesh.refine_all_elements();
// Initialize the shapeset and the cache
H1Shapeset shapeset;
PrecalcShapeset pss(&shapeset);
// Create finite element space
H1Space space(&mesh, &shapeset);
space.set_bc_types(bc_types);
space.set_bc_values(bc_values);
space.set_uniform_order(P_INIT);
// Enumerate basis functions
space.assign_dofs();
// Initialize the weak formulation
WeakForm wf(1);
wf.add_biform(0, 0, bilinear_form, bilinear_form_ord, SYM);
wf.add_liform(0, linear_form, linear_form_ord);
wf.add_liform_surf(0, linear_form_surf, linear_form_surf_ord, 2);
// Visualize solution and mesh
ScalarView sview("Coarse solution", 0, 100, 798, 700);
OrderView oview("Polynomial orders", 800, 100, 798, 700);
// Matrix solver
UmfpackSolver solver;
// Time measurement
double cpu = 0;
begin_time();
// Solve the problem
Solution sln;
LinSystem ls(&wf, &solver);
ls.set_spaces(1, &space);
ls.set_pss(1, &pss);
ls.assemble();
ls.solve(1, &sln);
// Time measurement
cpu += end_time();
// View the solution and mesh
sview.show(&sln);
oview.show(&space);
// Print timing information
verbose("Total running time: %g sec", cpu);
// wait for all views to be closed
View::wait("Waiting for all views to be closed.");
return 0;
}
示例11: ROS_DEBUG
void HeaderManipulation::publishMsg(const topic_tools::ShapeShifter &msg, const ros::Time &msg_in_time)
{
ROS_DEBUG("HeaderManipulation publishMsg Thread started with timestamp %f", msg_in_time.toSec());
ros::Time end_time(ros::Time::now());
ros::Time last_time;
config_mutex_.lock();
ros::Time time_to_pub(msg_in_time + msg_delay_);
config_mutex_.unlock();
do
{
last_time = end_time;
ROS_DEBUG("waiting to publish msg from %f at %f", msg_in_time.toSec(), time_to_pub.toSec());
if (end_time > time_to_pub)
{
boost::mutex::scoped_lock pub_lock(pub_mutex_);
ROS_DEBUG("publishing msg which should be held back till: %f", time_to_pub.toSec());
generic_pub_.publish(msg);
return;
}
boost::mutex::scoped_lock config_lock(config_mutex_);
publish_retry_rate_.sleep();
time_to_pub = msg_in_time + msg_delay_;
end_time = ros::Time::now();
} while (last_time <= end_time);
ROS_WARN("Detected jump back in time. Dropping msg. last: %f, end %f",
last_time.toSec(), end_time.toSec());
return;
}
示例12: rtInitRun
void rtInitRun()
{
#ifdef RT_TEST
frt_real Yp = 1.0e-10;
#else
frt_real Yp = constants->Yp;
#endif
frt_real Tmin = gas_temperature_floor;
frt_real D2GminH2 = rt_dust_to_gas_floor*(constants->Dsun/constants->Zsun);
frt_real CluFacH2 = rt_clumping_factor;
frt_real CohLenH2 = rt_coherence_length;
frt_real fGal = rt_uv_emissivity_stars;
frt_real fQSO = rt_uv_emissivity_quasars;
frt_intg IPOP = rt_stellar_pop;
frt_intg IREC = 0;
frt_intg IOUNIT = 81;
start_time(WORK_TIMER);
frtCall(initrun2)(&Yp,&Tmin,&D2GminH2,&CluFacH2,&CohLenH2,&fGal,&fQSO,&IPOP,&IREC,&IOUNIT);
end_time(WORK_TIMER);
#ifdef RT_TRANSFER
rtInitRunTransfer();
#endif
}
示例13: init_ga
void init_ga(int num_circles)
{
char *end_time_str;
struct timespec tp1, tp2;
int idx;
if(_is_initialized)
return;
printfl(IA_INFO,
"initializing for genetic algorithm, this may take some time....");
_is_initialized = true;
circle_pool = calloc(GEN_SIZE, sizeof(struct ia_circles *));
start_time(&tp1);
for(idx = 0; idx < GEN_SIZE; idx++) {
circle_pool[idx] = calloc(1, sizeof(struct ia_circles));
init_circles(circle_pool[idx], num_circles);
}
for(idx = 0; idx < GEN_SIZE; idx++) {
//for(jdx = 0; jdx < 2; jdx++) {
// _seed_mutate(&circle_pool[idx]);
//}
refresh_circles(circle_pool[idx]);
sort_circles(circle_pool[idx]);
}
end_time_str = end_time(&tp1, &tp2, "time");
printfi("%s\nsee, that didn't take too long, did it?\n", end_time_str);
free(end_time_str);
}
示例14: rtInitStep
void rtInitStep(double dt)
{
frt_real uDen = units->number_density;
frt_real uLen = units->length;
frt_real uTime = units->time;
frt_real dtCode = dt;
#ifdef COSMOLOGY
frt_real aExp = abox[min_level];
frt_real daExp = abox_from_tcode(tl[min_level]+dt) - abox[min_level];
frt_real HExp = Hubble(aExp)/units->time;
#else
frt_real aExp = 1.0;
frt_real daExp = 0.0;
frt_real HExp = 0.0;
#endif
start_time(WORK_TIMER);
frtCall(stepbegin)(&uDen,&uLen,&uTime,&aExp,&HExp,&daExp,&dtCode);
end_time(WORK_TIMER);
#ifdef RT_TRANSFER
rtInitStepTransfer();
#endif
rtUpdateTables();
#ifdef RT_DEBUG
switch(rt_debug.Mode)
{
case 1:
{
int i, cell;
cell = cell_find_position(rt_debug.Pos);
cart_debug("In cell-level debug for cell %d/%d",cell,cell_level(cell));
cart_debug("RT_HVAR_OFFSET: %d",RT_HVAR_OFFSET);
#ifdef RT_VAR_SOURCE
cart_debug("RT_VAR_SOURCE: %d",RT_VAR_SOURCE);
#endif
cart_debug("rt_grav_vars_offset: %d",rt_grav_vars_offset);
#ifdef RT_TRANSFER
cart_debug("rt_num_vars: %d",rt_num_vars);
#if (RT_TRANSFER_METHOD == RT_METHOD_OTVET)
cart_debug("RT_VAR_OT_FIELD: %d",RT_VAR_OT_FIELD);
cart_debug("rt_et_offset: %d",rt_et_offset);
cart_debug("rt_field_offset: %d",rt_field_offset);
#endif
#endif
for(i=0; i<num_vars; i++)
{
cart_debug("Var[%d] = %g",i,cell_var(cell,i));
}
break;
}
}
#endif /* RT_DEBUG */
}
示例15: min
void Control::initTime()
{
QSqlQuery query;
QDateTime start_date_time;
query.exec("select min(DATE),min(TIME) from DATAS");
if(query.next()){
int min_date = query.value(0).toInt();
int min_time = query.value(1).toInt();
int year = min_date / 10000;
int month = min_date % 10000 / 100;
int day = min_date % 100;
int h = min_time / 10000;
QTime start_time(h,0);
QDate start_date(2000 +year,month,day);
start_date_time = QDateTime(start_date,start_time);
}
query.exec("select max(DATE),max(TIME) from DATAS");
QDateTime end_date_time;
if(query.next()){
int max_date = query.value(0).toInt();
int max_time = query.value(1).toInt();
int year = max_date / 10000;
int month = max_date % 10000 / 100;
int day = max_date % 100;
int h = max_time / 10000;
QTime end_time(h,0);
QDate end_date(2000 +year,month,day);
end_date_time = QDateTime(end_date,end_time);
}
ui->startDateTimeEdit->setDisplayFormat("yyyy-M-d HH");
ui->endDateTimeEdit->setDisplayFormat("yyyy-M-d HH");
ui->startDateTimeEdit->setMinimumDateTime(start_date_time);
ui->startDateTimeEdit->setMaximumDateTime(end_date_time);
ui->endDateTimeEdit->setMinimumDateTime(start_date_time);
ui->endDateTimeEdit->setMaximumDateTime(end_date_time);
ui->startDateTimeEdit_2->setDisplayFormat("yyyy-M-d HH");
ui->endDateTimeEdit_2->setDisplayFormat("yyyy-M-d HH");
ui->startDateTimeEdit_2->setMinimumDateTime(start_date_time);
ui->startDateTimeEdit_2->setMaximumDateTime(end_date_time);
ui->endDateTimeEdit_2->setMinimumDateTime(start_date_time);
ui->endDateTimeEdit_2->setMaximumDateTime(end_date_time);
ui->startDateTimeEdit_3->setDisplayFormat("yyyy-M-d HH");
ui->endDateTimeEdit_3->setDisplayFormat("yyyy-M-d HH");
ui->startDateTimeEdit_3->setMinimumDateTime(start_date_time);
ui->startDateTimeEdit_3->setMaximumDateTime(end_date_time);
ui->endDateTimeEdit_3->setMinimumDateTime(start_date_time);
ui->endDateTimeEdit_3->setMaximumDateTime(end_date_time);
ui->startDateTimeEdit_4->setDisplayFormat("yyyy-M-d HH");
ui->endDateTimeEdit_4->setDisplayFormat("yyyy-M-d HH");
ui->startDateTimeEdit_4->setMinimumDateTime(start_date_time);
ui->startDateTimeEdit_4->setMaximumDateTime(end_date_time);
ui->endDateTimeEdit_4->setMinimumDateTime(start_date_time);
ui->endDateTimeEdit_4->setMaximumDateTime(end_date_time);
}