本文整理汇总了C++中TimeStat::reset方法的典型用法代码示例。如果您正苦于以下问题:C++ TimeStat::reset方法的具体用法?C++ TimeStat::reset怎么用?C++ TimeStat::reset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimeStat
的用法示例。
在下文中一共展示了TimeStat::reset方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handle
//.........这里部分代码省略.........
ad_info.updateTime = -1;
} else {
ad_info.updateTime = 0;
}
ad_info_seq.push_back(ad_info);
//call AdLogAdapter
Ice::Long zone_id = log_para.zone_id_;
Ice::Long creativeid = log_para.creative_id_;
string http = LogHelper::instance().MakeHttp(log_para);
string ip = LogHelper::instance().MakeIp(profile.ip());
int uid = profile.id();
string deal_referer = para.referer_;
LogHelper::instance().Process(deal_referer);
MCE_DEBUG("LogHandler::handle-->gid:"<<(*sit)->group_->group_id()<<",pos:" <<(*sit)->pos_);
//int sort_type = EngineConfig::instance().sort_type();
int sort_type = EngineConfig::instance().server_index();
//transtype修改,现在写的是数据库里读出来的,不再是写死的
//display_type:1=轮播, 2= cpm ,3=余量, 4= cpc, 5=产品
double cost = log_para.cost_;
if(group_ptr->IsCpm()){
log << setprecision(5);
} else if(group_ptr->IsCpc()){//cpc的pv cost=0,cpm为相应扣费
log << setprecision(0);
cost = 0;
}
log << EngineConfig::instance().server_name() << "||" << ip << "||" << date.toDateTime() << "||\"GET "
<< http << " HTTP/1.0\"||200||undefined||" << log_para.session_id_ << "||undefined||" << group_ptr->trans_type() << "||" << sort_type << "||none||"
<< deal_referer << "||" << zone_id << "^B^B^B^B^B^B^B||" << creativeid << "^B" << group_ptr->member_id()
<< "^B" << group_ptr->bid_unit_id() << "^B" << setiosflags(ios::fixed) << cost << setiosflags(ios::scientific) << setprecision(6)
<< "^B" << group_ptr->max_price(zone_id) << "^B" << deal_referer
<< "^B" << log_para.pos_ <<"^B" << log_para.demo_state_ << "^B2^B"<<log_para.demo_ctr_<<"||" << group_ptr->display_type();
if((!log_para.append_info_.empty()) && (log_para.append_info_.compare("-") != 0)) {
log << "||" << log_para.append_info_;
}
pv_log_seq.push_back(log.str());
log.str("");
if(group_ptr->IsCpm()){//cpm
//cpm价格具体逻辑写在caculate_cost里面,要/1000
cpm_log << log_para.creative_id_ << ',' << group_id << ','
<< group_ptr->campaign_id() << ',' << group_ptr->member_id() << ',' << log_para.zone_id_ << ','
<< LogHelper::instance().FormatedClickTime(time(NULL)) << ',' << setiosflags(ios::fixed) << setprecision(5)
<< log_para.cost_ << ',' << group_ptr->bid_unit_id() << ',' << uid << ',' << '0';
cpm_log_seq.push_back(cpm_log.str());
cpm_log.str("");
}
}
/*engine_log << "pvlog=1\tuserid=" << profile.id() << "\tage="<< profile.age()
<< "\tgender="<< profile.gender() << "\tstage=" << profile.stage()
<< "\tgrade=" << profile.grade() << "\tcurrent_area="
<< ((profile.current_area().empty()) ? "-" : profile.current_area())
<< "\tip_area=" << ((profile.ip_area().empty()) ? "-" : profile.ip_area())
<< "\tschool=" << profile.school() << "\tzone_id=" << para.adzone_->id()
<< "\tgroup_id=" << group_ptr->group_id() << "\tmax_price=" << group_ptr->max_price(zone_id)
<< "\tapp_id=" << LogHelper::instance().GetAppId(para.referer_)
<< "\tmember_id=" << group_ptr->member_id() << "\tsystem_time=" << date.toDateTime();
engine_log_seq.push_back(engine_log.str());
engine_log.str("");*/
result[para.adzone_->id()] = ad_info_seq;
try {
subts.reset();
AdLogAdapter::instance().PvBatch(pv_log_seq);
STATISTICS("LogHandler::handle --> TIME_TEST write pv_log : " << subts.getTime());
} catch (Ice::Exception& e) {
MCE_WARN("LogHandler::handle AdLogAdapter.PvBatch ERR line:" << __LINE__ << " err:" << e);
} catch (std::exception& e) {
MCE_WARN("LogHandler::handle AdLogAdapter.PvBatch ERR line:" << __LINE__ << " err:" << e.what());
}
////////////////
if(!cpm_log_seq.empty()){//cpm单独打charge_pv
try {
AdLogAdapter::instance().PvForCharge(cpm_log_seq);
} catch (Ice::Exception& e) {
MCE_WARN("LogHandler::handle AdLogAdapter.CpmBatch ERR line:" << __LINE__ << " err:" << e);
} catch (std::exception& e) {
MCE_WARN("LogHandler::handle AdLogAdapter.CpmBatch ERR line:" << __LINE__ << " err:" << e.what());
}
}
/*try {
subts.reset();
AdLogAdapter::instance().EngineLogBatch(engine_log_seq);
STATISTICS("LogHandler::handle --> TIME_TEST write engine_log : "
<< subts.getTime());
} catch (Ice::Exception& e) {
MCE_WARN("LogHandler::handle AdLogAdapter.EngineLogBatch ERR line:"
<< __LINE__ << " err:" << e);
} catch (std::exception& e) {
MCE_WARN("LogHandler::handle AdLogAdapter.EngineLogBatch ERR line:"
<< __LINE__ << " err:" << e.what());
}*/
//STATISTICS("LogHandler::handle --> time = " << ts.getTime());
return true;
}
示例2: GetAds
AdResultMap AdMatchManagerI::GetAds(const string& userProfile, const string& referer, int rotate_index, const Ice::Current& current){
MCE_INFO("AdMatchNManagerI::GetAds --> call from " << current.con->toString());
ostringstream timelog;
TimeStat ts;
TimeStat subts;
AdResultMap ans;
UserProfile profile;
ostringstream info;
set<AdGroupPtr> selected;
bool hide = false;
Ice::Context::const_iterator i = current.ctx.find("hide");
if (i != current.ctx.end() && i->second == "true") {
hide = true;
}
bool get_ad_success = true;
UserProfileClient::instance().Deserialize(userProfile, &profile);
timelog << " after Deserialize time_cost = " << ts.getTime();
if(!init_ok_){
MCE_INFO("AdMatchNManagerI::GetAds --> initing.......");
return ans;
}
LogHelper::instance().CookieEmptyCheck(profile);
timelog << " after CookieEmptyCheck time_cost = " << ts.getTime();
info << "uid = "<<profile.id()<<",age = " << profile.age() << ",gender = "<< profile.gender() <<
",stage = " << profile.stage() << ",grade = " << profile.grade() <<
",current_area = " << profile.current_area() << ",ip_area = " << profile.ip_area() << ",school =" << profile.school();
//MCE_INFO("AdMatchNManagerI::GetAds -->~~~~~~~~~~~~~~~~~~~~~rotate_index = " << rotate_index << " " << info.str());
uint64_t user_key = Translator::instance().GetIndex(profile);
subts.reset();
AdZoneDict zone_dict = AdZonePool::instance().GetAdZoneOrdered(referer, profile.stage(), hide);
//MCE_DEBUG("[VIP_DEBUG] uid = " << profile.id() << ", hide = " << hide);
timelog << " after GetAdZoneOrdered2 time_cost = " << ts.getTime();
if(zone_dict.empty()){
//MCE_WARN("AdMatchNManagerI::GetAds --> No Result For GetAdZoneOrdered referer = " << referer);
return ans;
}
//MCE_INFO("AdMatchNManagerI::GetAds --> AdZoneDict->size = " << zone_dict.size());
//MCE_INFO("AdMatchNManagerI::GetAds --> TIME_TEST GetAdZoneOrdered = " << subts.getTime());
//////////////////////////////////////////////////////////
FilterBindUser(zone_dict, ans, profile.id());
timelog << " after FilterBindUser time_cost = " << ts.getTime();
//////////////////////////////////////////////////////////
for(AdZoneDict::iterator it = zone_dict.begin(); it != zone_dict.end(); ++it){
//MCE_INFO("AdMatchNManagerI::GetAds --> process adzone : " << it->second->id());
ostringstream zone_debug_log;
set<AdGroupPtr> zone_selected;
map<Ice::Long, int> group_costs;
AdZonePtr zone = it->second;
Ice::Long zone_id = it->second->id();
zone_debug_log << "[ZONE_DEBUG] adzone_id = " << zone_id << ", ";
int ad_count = it->second->ad_count();
int rotate_size = it->second->GetRotateSize();
int zone_rotate_index = 0;
if(rotate_size){
zone_rotate_index = rotate_index % rotate_size;
}
zone_debug_log << "zone_rotate_index = " << zone_rotate_index << ", ";
//**MCE_INFO("AdMatchNManagerI::GetAds --> @@@@@@@@@@@@@@@@@ zone_id = " << zone_id << " ad_count = " << ad_count << " rotate_size = " << rotate_size << " rotate_index = " << rotate_index << " zone_rotate_index = " << zone_rotate_index);
subts.reset();
AdGroupPtr rotate_group_ptr = it->second->GetRotateGroups(zone_rotate_index, user_key);
//MCE_INFO("AdMatchNManagerI::GetAds --> TIME_TEST GetRotateGroups = " << subts.getTime());
//MCE_INFO("AdMatchNManagerI::GetAds --> [email protected] ad_count = " << ad_count << " zone_id = " << zone_id << " rotate_size = " << rotate_size);
if(rotate_group_ptr){
set<AdGroupPtr> rotate_set;
rotate_set.insert(rotate_group_ptr);
AdRanker::instance().Filter(rotate_set, selected);
if(!rotate_set.empty()){
zone_debug_log << "has rotate_group = " << rotate_group_ptr->group_id() << ", ";
zone_selected.insert(rotate_group_ptr);
//MCE_INFO("AdMatchNManagerI::GetAds ==> zone_id = " << zone_id << " ad_count = " << ad_count << " GET ROTATE SUCCESS, group_id = " << rotate_group_ptr->group_id() <<" zone_rotate_index = " << zone_rotate_index);
ad_count--;
}
else{
//**MCE_INFO("AdMatchNManagerI::GetAds ==>Get ROTATE ad from AdZone : " << zone_id << " zone_rotate_index = " << zone_rotate_index << " AFTER RANK FAILED !!!! adgroup_id = " << rotate_group_ptr->group_id() << " bid_unit_id = " << rotate_group_ptr->bid_unit_id() << " bid_unit_key = " << rotate_group_ptr->bid_unit_key() << " userkey = " << user_key);
}
} else {
zone_debug_log << "has no rotate_group, ";
if ((zone->member_type() == 0) && ((rotate_size - zone_rotate_index) <= zone->self_rotation_number())) {
MCE_INFO("AdMatchNManagerI::GetAds --> need ad from AdEngine/Tw: uid = " << profile.id() << ", zone_id = " << zone->id() << ", rotate_index = " << zone_rotate_index);
AdInfoSeq ad_info_seq;
AdInfo ad_info;
ad_info.groupid = -1;
ad_info_seq.push_back(ad_info);
ans[zone->id()] = ad_info_seq;
//.........这里部分代码省略.........