Directory::Entry::Type ScanningWatch::type(const Stat& stbuf) { #ifdef _WIN32 if (stbuf.ISDEV()) { return Directory::Entry::TYPE_DEV; } else if (stbuf.ISDIR()) { return Directory::Entry::TYPE_DIR; } else if (stbuf.ISREG()) { return Directory::Entry::TYPE_REG; } #else if (stbuf.ISBLK()) { return Directory::Entry::TYPE_BLK; } else if (stbuf.ISCHR()) { return Directory::Entry::TYPE_CHR; } else if (stbuf.ISDIR()) { return Directory::Entry::TYPE_DIR; } else if (stbuf.ISFIFO()) { return Directory::Entry::TYPE_FIFO; } else if (stbuf.ISLNK()) { return Directory::Entry::TYPE_LNK; } else if (stbuf.ISREG()) { return Directory::Entry::TYPE_REG; } else if (stbuf.ISSOCK()) { return Directory::Entry::TYPE_SOCK; } #endif else { debug_break(); return Directory::Entry::TYPE_REG; } }
void AMerge::clear_src() { cout << "Remove source files ..." << flush; foreach( fs::path dir, _directories ) { Stat status; status.scan_directory( dir, SCAN_MODE_RECURSIVE | SCAN_MODE_FILES | SCAN_MODE_DIRS ); status.remove(); }
bool ScanningWatch::equals(const Stat& left, const Stat& right) { return type(left) == type(right) && left.get_mtime() == right.get_mtime() && left.get_size() == right.get_size(); }
void Actors::calculateCreatureStatModifiers (const MWWorld::Ptr& ptr) { CreatureStats &creatureStats = MWWorld::Class::get(ptr).getCreatureStats(ptr); const MagicEffects &effects = creatureStats.getMagicEffects(); // attributes for(int i = 0;i < ESM::Attribute::Length;++i) { Stat<int> stat = creatureStats.getAttribute(i); stat.setModifier(effects.get(EffectKey(ESM::MagicEffect::FortifyAttribute, i)).mMagnitude - effects.get(EffectKey(ESM::MagicEffect::DrainAttribute, i)).mMagnitude); creatureStats.setAttribute(i, stat); } // dynamic stats for(int i = 0;i < 3;++i) { DynamicStat<float> stat = creatureStats.getDynamic(i); stat.setModifier(effects.get(EffectKey(80+i)).mMagnitude - effects.get(EffectKey(18+i)).mMagnitude); creatureStats.setDynamic(i, stat); } }
void CSStats::readFromXML( const std::string& entityID, const pugi::xml_node& node ) { CStats component; for( pugi::xml_node statNode : node ) { Stat stat; pugi::xml_attribute idAtt = statNode.attribute( "id" ); if( !idAtt ) { DOS_ERROR( true, "Unable to load entity Stat. ID is missing" ); continue; } stat.setID( idAtt.as_int() ); pugi::xml_attribute valueAtt = statNode.attribute( "value" ); if( !valueAtt ) { DOS_ERROR( true, "Unable to load entity Stat. Value is missing" ); continue; } stat.setBase( valueAtt.as_float() ); component.stats.push_back( stat ); } COMPONENT_MANAGER.addProperty( component, entityID ); }
void PIOS::print_stats(run_arg *args) { char regionstr[32], chunkstr[32], mbstr[32]; cfs_duration_t highest, lowest, average; __u64 agvsize; Stat *st = args->st; assert(st != NULL); st->Record("%d\t%s\t%llu\t%d\t%llu\t%s\t%s\t", args->runno, args->verify ? "Read" : "Write", args->startime, args->threadcount, args->regioncount, in_MBs(regionstr, args->regionsize), in_MBs(chunkstr, args->chunksize)); /* TODO: chunk noise */ assert(args->chunknoise == 0); agvsize = args->regionsize * args->regioncount; find_high_low_duration(args, &highest, &lowest, &average); in_MBs(mbstr, agvsize * params.TimeUnit / args->iotime); st->Record("%s/s\t\t%2.3fs\t%2.3fs\t%2.3fs\n", mbstr, ((double)(lowest / 1000000)) / 1000.0, ((double)(highest / 1000000)) / 1000.0, ((double)(args->iotime / 1000000)) / 1000.0); }
int test3() { srand(time(NULL)); std::cout << "QUICKSORT" << std::endl; Float<&sort> tab2[20]; int i,taille = 500; std::cout << "creation du tableau" << std::endl; for(i=0;i<taille;i++) { tab2[i] = 1 + (int)(((double)rand())/((double)RAND_MAX+1)*(double)1000); } sort.time_reset(); std::cout << "triage du tableau" << std::endl; quicksort<&sort>(tab2,0,taille); std::cout << "["; for (int i=0; i<taille; i++) { std::cout << tab2[i]; if (i < taille - 1) std::cout << ", "; if (i%20==1) std::cout << std::endl; } std::cout << "]" << std::endl; sort.show_stats(); return 0; }
bool connectionValid(int mask, Stat S){ for (int i = 0; i < 5; i++) if (maskGet(mask, i)){ Stat::iterator it = SSfind(S, i); if (it != S.end()) S.erase(it); } return S.empty(); }
void Print_Me(){ printf("Score_Stats: "); Score.Print_Me(); printf("\n"); printf("Length_Stats: "); FinalGen.Print_Me(); printf("\n"); }
static void connect_server(int thread_id, int repead_id, string host, int port) { char peerid[21], ip[16]; snprintf(peerid, 20, "%10d%10d", thread_id, repead_id); peerid[20] = '\0'; snprintf(ip, 15, "%d.%d.%d.%d", thread_id & 0x000000ff, repead_id & 0x000000ff, port & 0x000000ff, host[0] & 0x000000ff); ip[15] = '\0'; Peer peer; peer.__set_ip(ip); peer.__set_idc("tc"); peer.__set_port(host[1] & 0x000000ff); peer.__set_peerid(peerid); Stat stat; stat.__set_downloaded(thread_id * repead_id); stat.__set_left(thread_id + repead_id); stat.__set_uploaded(thread_id); stat.__set_status(static_cast<Status::type>(thread_id * repead_id % 5)); AnnounceRequest request; request.__set_infohash("abcdefghijklmnopqrst"); request.__set_is_seed(thread_id * repead_id % 2); request.__set_num_want(50); request.__set_peer(peer); request.__set_stat(stat); //printf("%s:%d peerid: %s, infohash: %s, is_seed: %d, status: %d\n", ip, peer.port, peer.peerid.c_str(), request.infohash.c_str(), request.is_seed, stat.status); AnnounceResponse response; shared_ptr<TSocket> socket(new TSocket(host.c_str(), port)); socket->setConnTimeout(3000); socket->setSendTimeout(3000); socket->setRecvTimeout(5000); shared_ptr<TTransport> transport(new TFramedTransport(socket)); shared_ptr<TBinaryProtocol> protocol(new TBinaryProtocol(transport)); AnnounceClient client(protocol); try { transport->open(); client.announce(response, request); transport->close(); //printf("success\n"); } catch (TException &tx) { printf("ERROR: %s\n", tx.what()); return; } #if 0 printf("/*************************************************************/\n"); printf("%s:%d peerid: %s, infohash: %s, is_seed: %d, status: %d\n", ip, peer.port, peerid, request.infohash.c_str(), request.is_seed, stat.status); printf("ret: %d, failure_reason: %s, min_interval: %d, have_seed: %d, peers_num: %ld\n" , response.ret, response.failure_reason.c_str(), response.min_interval, response.have_seed, response.peers.size()); for (std::vector<Peer>::iterator it = response.peers.begin(); it != response.peers.end(); ++it) { printf("%s:%d\n", it->ip.c_str(), it->port); } printf("/*************************************************************\n"); #endif }
void CSStats::applyHPRegen( CStats& component ) { Stat* health = component.getStat( Stat::SID_Health ); if( health ) { Stat* hpRegen = component.getStat( Stat::SID_HPRegen ); if( hpRegen ) { health->change( hpRegen->max ); } } }
void SScombine(Stat &S, int i, int j){ Stat::iterator iti = SSfind(S, i); Stat::iterator itj = SSfind(S, j); if (iti == itj) return; set<int> s(*iti); for (set<int>::iterator it = itj->begin(); it != itj->end(); it++){ s.insert(*it); } S.erase(iti); S.erase(itj); S.insert(s); }
int test1() { //st.time_reset(); naive.time_reset(); std::cout << "SOMME NAIVE" << std::endl; sommeNaive<&naive>(1,32000); naive.show_stats(); std::cout << std::endl; //gauss.time_reset(); std::cout << "SOMME DE GAUSS" << std::endl; sommeGauss<&gauss>(1,320); gauss.show_stats(); std::cout << std::endl; //std::cout << "TRI BULLES" << std::endl; std::cout << "TRI SELECTION" << std::endl; int taille = 10; Float<&s> tab1[10] = {12.1,48.3,5.4,9,1.7,20.5,1.3,24.5,3,7}; // triBulles<&s>(tab,taille); // s.time_reset(); triSelection<&s>(tab1,taille); std::cout << "["; for (int i=0; i<taille; i++) { std::cout << tab1[i]; if (i < taille-1) std::cout << ", "; } std::cout << "]" << std::endl; s.show_stats(); // sort.time_reset(); std::cout << "QUICKSORT" << std::endl; Float<&sort> tab2[20]; int i; for(i=0;i<20;i++) { tab2[i]=20-i; } quicksort<&sort>(tab2,0,19); std::cout << "["; for (int i=0; i<20; i++) { std::cout << tab2[i]; if (i < 19) std::cout << ", "; } std::cout << "]" << std::endl; sort.show_stats(); return 0; }
void StatisticsBase::safeFlushInformation(int fd) const { #ifdef CVC4_STATISTICS_ON for (StatSet::iterator i = d_stats.begin(); i != d_stats.end(); ++i) { Stat* s = *i; if (d_prefix.size() != 0) { safe_print(fd, d_prefix); safe_print(fd, s_regDelim); } s->safeFlushStat(fd); safe_print(fd, "\n"); } #endif /* CVC4_STATISTICS_ON */ }
string strFromStat(Stat S){ string s; for (Stat::iterator it = S.begin(); it != S.end(); it++){ string tmp = "{"; for (set<int>::iterator i = it->begin(); i != it->end(); i++){ tmp += strFromInt(*i) + ", "; } tmp[tmp.size() - 2] = '}'; tmp[tmp.size() - 1] = ' '; s += tmp; } return s; }
Stat getStat0(int m){ Stat S; set<int> cur; for (int i = 0; i < 5; i++) if (maskGet(m, i)) { if (i != 0 && !maskGet(m, i - 1) ){ if (!cur.empty()) S.insert(cur); cur.clear(); } cur.insert(i); } if (!cur.empty()) S.insert(cur); return S; }
/* 测量项目other在min和max之间的人找出来,统计他们的item的值 */ void Query::query_data_by_others(Stat &stat, QString item, QString other, float min, float max) { stat.reset(); for (int i = 0; i < npeople; i++) { float other_data = get_data_by_item(&people[i], other); if (other_data <= max && other_data >= min) { float data = get_data_by_item(&people[i], item); if (data != -1) { stat.add_element(data); } } } }
void StatisticsBase::flushInformation(std::ostream &out) const { #ifdef CVC4_STATISTICS_ON for(StatSet::iterator i = d_stats.begin(); i != d_stats.end(); ++i) { Stat* s = *i; if(d_prefix != "") { out << d_prefix << s_regDelim; } s->flushStat(out); out << std::endl; } #endif /* CVC4_STATISTICS_ON */ }
/// Set modified value an adjust base accordingly. void setModified (T value, const T& min, const T& max = std::numeric_limits<T>::max()) { mStatic.setModified (value, min, max); if (mCurrent>getModified()) mCurrent = getModified(); }
/// Set base and adjust modified accordingly. void setBase (const T& value) { mStatic.setBase (value); if (mCurrent>getModified()) mCurrent = getModified(); }
void Query::query_data(Stat &stat, QString item, QString nativeplace, QString district, QString armtype, QString education, QString militaryrank) { int pm; QList<int> parameters; stat.reset(); if (item == "") return; parameters << get_value_by_key(nativeplace_map, nativeplace); parameters << get_value_by_key(district_map, district); parameters << get_value_by_key(armtype_map, armtype); parameters << get_value_by_key(education_map, education); parameters << get_value_by_key(militaryrank_map, militaryrank); pm = 0; while (pm < PARAMETER_SIZE && parameters[pm] == -1) { pm++; } if (pm == PARAMETER_SIZE) { for (int i = 0; i < this->npeople; i++) { People *p = &people[i]; float item_data = get_data_by_item(p, item); if (item_data > 0) { stat.add_element(item_data); } } } else { List *l = find_list(parameters[pm], pm); People *p = l->first; while (p) { bool all_parameter_match = true; for (int ii = pm + 1; ii < PARAMETER_SIZE; ii++) { if (parameters[ii] != -1 && !match_parameter(p, ii, parameters[ii])) { all_parameter_match = false; break; } } float item_data = get_data_by_item(p, item); if (all_parameter_match && item_data > 0) { stat.add_element(item_data); } p = p->next[pm]; } } }
bool ResultsGenerator::NextResult(Result& out) { // check if there are still remaining parts auto pRemain = m_remains.begin(); for (; pRemain != m_remains.end(); pRemain++) if (*pRemain > 0) break; if (pRemain == m_remains.end()) return false; // no more parts Result bestResult; Amounts bestRashod(m_remains.size()); bool first = true; m_layout2d.ResetCompletedCounter(); for (auto pSheet = m_sheets.begin(); pSheet != m_sheets.end(); pSheet++) { Stat stat; stat.MakeZero(); OldLayoutResult raskroy; Amounts rashod(m_remains.size()); if (!m_layout2d.Optimize(pSheet->rect, stat, 0, raskroy, rashod)) continue; if (bestResult.Statistics < stat || first) { bestResult.amount = m_remains / rashod; if (ControlRemains && bestResult.amount > pSheet->Amount) continue; // not enough sheets bestResult.Statistics = stat; bestResult.raskroy = raskroy; bestResult.sheet = pSheet; bestRashod = rashod; first = false; } } if (first) throw CannotSetPartsException(&m_sheets, m_sizes, &m_remains); m_remains -= bestRashod * bestResult.amount; RemoveExostedSizes(); if (ControlRemains) bestResult.sheet->Amount -= bestResult.amount; #ifdef _DEBUG CheckResult(bestResult); #endif out = bestResult; return true; }
void main( void ) { const int NUM = 9; int array[NUM]; time_t t; srand((unsigned) time(&t)); cout << "Vector: "; for (int i=0; i < NUM; i++) { array[i] = rand() % 9 + 1; cout << array[i] << ' '; } cout << endl; Stat obj; obj.readVector( array, NUM ); cout << "min is " << obj.getMin() << ", max is " << obj.getMax() << ", median is " << obj.getMed() << endl; }
virtual bool read(ConnectionReader& connection) { double now = Time::now(); Bottle b; bool ok = b.read(connection); if (ok) { mutex.wait(); ct++; if (ct>1) { double dt = now - lastTime; period.add(dt); } lastTime = now; printf("Period is %g +/- %g (%d)\n", period.mean(), period.deviation(), ct); mutex.post(); } return ok; }
Stat newStat(Stat S, int mask){ set<set<int> > T; for (int i = 0; i < 5; i++) if (maskGet(mask, i)){ SSinsertNew(T, i); if (i != 0 && maskGet(mask, i - 1)) SScombine(T, i, i - 1); for (int j = 0; j < i; j++) if (maskGet(mask, j)){ if (SSfind(S, i) == S.end()) continue; if (SSfind(S, i) == SSfind(S, j)) SScombine(T, i, j); } } return T; }
void cleanup() { Stat stat; stat.scan_directory( fs::path(".test"), SCAN_MODE_RECURSIVE | SCAN_MODE_FILES | SCAN_MODE_DIRS ); stat.sort(); std::reverse( stat.begin(), stat.end() ); stat.remove(); fs::remove( fs::path(".test") ); }
ProcStats::ProcStats(AggregateStat* parentStat, AggregateStat* _coreStats) : coreStats(_coreStats) { uint32_t maxProcs = zinfo->lineSize; lastUpdatePhase = 0; // Check that coreStats are appropriate assert(coreStats); for (uint32_t i = 0; i < coreStats->size(); i++) { Stat* s = coreStats->get(i); AggregateStat* as = dynamic_cast<AggregateStat*>(s); auto err = [s](const char* reason) { panic("Stat %s is not per-core (%s)", s->name(), reason); }; if (!as) err("not aggregate stat"); if (!as->isRegular()) err("irregular aggregate"); if (as->size() != zinfo->numCores) err("elems != cores"); } // Initialize all the buffers bufSize = StatSize(coreStats); buf = gm_calloc<uint64_t>(bufSize); lastBuf = gm_calloc<uint64_t>(bufSize); // Create the procStats procStats = new AggregateStat(true); procStats->init("procStats", "Per-process stats"); for (uint32_t p = 0; p < maxProcs; p++) { AggregateStat* ps = new AggregateStat(false); const char* name = gm_strdup(("procStats-" + Str(p)).c_str()); ps->init(name, "Per-process stats"); for (uint32_t i = 0; i < coreStats->size(); i++) { AggregateStat* as = dynamic_cast<AggregateStat*>(coreStats->get(i)); assert(as && as->isRegular()); ps->append(replStat(as->get(0), as->name(), as->desc())); } procStats->append(ps); } parentStat->append(procStats); }
AggregateStat* FilterStatsLevel(const AggregateStat* src, const regex& filter, const char* prefix) { string base = prefix? (string(prefix) + src->name() + ".") : ""; //if NULL prefix, omit our name (we're root) vector<Stat*> children; for (uint32_t i = 0; i < src->size(); i++) { Stat* child = src->get(i); if (AggregateStat* as = dynamic_cast<AggregateStat*>(child)) { AggregateStat* fs = FilterStatsLevel(as, filter, base.c_str()); if (fs) children.push_back(fs); } else { string name = base + child->name(); if (regex_match(name, filter)) children.push_back(child); } } if (children.size()) { AggregateStat* res = new AggregateStat(src->isRegular()); res->init(src->name(), src->desc()); for (Stat* c : children) res->append(c); return res; } else { return NULL; } }
void EntityAction::handleStat( Entity& entity ) { CStats* cStats = entity.get<CStats>(); if( !cStats ) { return; } Stat* health = cStats->getStat( Stat::SID_Health ); if( !health ) { return; } if( stat == EAStat_Damage ) { // Temp, min-max should be randomized in RNG if( health->change( -maxValue ) ) { // Temp, should be replaced by some message MSG_SYSTEM.send( c_msgEnemyDied, entity ); } } else if( stat == EAStat_Heal ) { health->change( maxValue ); } }
void OldLayoutResult::CheckAndCalcStat(scalar cutThickness, const Rect& rect, Stat* outStat) const { Stat stat; stat.MakeZero(); stat.Opilki += (double)rect.Size[!s] * (double)std::min(cutThickness, rect.Size[s] - (cut + cutThickness) * kratnostj + cutThickness); scalar detailsWithCutsLength = 0; unsigned cuts = 0; for(Details::const_iterator i = details.begin(); i != details.end(); i++) { detailsWithCutsLength += (i->size + cutThickness) * i->num; cuts += i->num; } stat.Opilki += ((cut + cutThickness) * kratnostj - cutThickness) * std::min(cutThickness, rect.Size[!s] - detailsWithCutsLength + cutThickness); stat.Opilki += (detailsWithCutsLength - cutThickness) * cutThickness * (kratnostj - 1); stat.Opilki += cut * cutThickness * (cuts - 1) * kratnostj; Stat remainStat; Rect remainRect; remainRect.Size[s] = std::max<scalar>((cut + cutThickness) * kratnostj - cutThickness, 0); remainRect.Size[!s] = std::max<scalar>(rect.Size[!s] - detailsWithCutsLength, 0); if(premain != 0) { premain->CheckAndCalcStat(cutThickness, remainRect, &remainStat); } else { remainStat.MakeZero(); remainStat.AddScrap(remainRect); } stat += remainStat; Stat recurseStat; Rect recurseRect; recurseRect.Size[s] = std::max<scalar>(rect.Size[s] - (cut + cutThickness) * kratnostj, 0); recurseRect.Size[!s] = rect.Size[!s]; if(precurse != 0) { precurse->CheckAndCalcStat(cutThickness, recurseRect, &recurseStat); } else { recurseStat.MakeZero(); recurseStat.AddScrap(recurseRect); } stat += recurseStat; *outStat = stat; }