/* * Optionally print, then initialize analysis statistics gathered here. */ Eximpl void /*ARGSUSED*/ spana_stats( Bool withprint ) { #if SPANA_STATS register int i; if( withprint && (f_stats > 0) ) { if( sc_mdb ) { printf("mdb:"); show_scs(1,9, sc_mdb , " calls,"); show_scs(1,9, sc_mdb_done, " done"); printf(" [%5.1f%%]\n", percent(sc_mdb_done, sc_mdb)); for( i=0 ; i<(ANA_MANY+1) ; ++i ) { if( sc_mdb_base[i] || sc_mdb_resu[i] ) { printf("mdb in/out %2d:", i); show_nz(0,10, '-', sc_mdb_base[i]); show_nz(1,10, '-', sc_mdb_resu[i]); printf(" [%6.2f%%]\n", percent(sc_mdb_resu[i], sc_mdb)); } } } } sc_mdb = 0; sc_mdb_done = 0; for( i=0 ; i<(ANA_MANY+1) ; ++i ) { sc_mdb_base[i] = 0; sc_mdb_resu[i] = 0; } #endif /* SPANA_STATS */ }
void reviewSanity(int dirCount, char *dirs[]) /* reviewSanity - Look through sanity files and make sure things are ok.. */ { int i; missLog = mustOpen("miss.log", "w"); for (i=0; i<=10; ++i) thresholds[i] = round((double)i*blockSize/10.0); for (i=0; i<dirCount; ++i) reviewOne(dirs[i]); printf("%d blocks, %d duplicates (%4.2f%%)\n", blockCount, dupeCount, percent(dupeCount, blockCount)); #ifdef OLD printf("%d perfect (%4.2f%%)\n", perfectCount, percent(perfectCount, blockCount)); printf("%d repeat masked out blocks\n", repMaskedCount); #endif /* OLD */ printf("\n"); printf("Ali Size\tNumber\tPercent\n"); printf("-------------------------\n"); printf(" none \t%d\t%4.2f%%\n", missCount, percent(missCount, blockCount)); for (i=0; i<10; ++i) { printf(" %3d-%d\t%d\t%4.2f%%\n", thresholds[i]+1, thresholds[i+1], hitCount[i], percent(hitCount[i], blockCount)); } }
// // compress() is the public function used to compress // a single file. It has to take care of opening the // input and output files and setting up the buffers for // Zlib. It then calls deflate() repeatedly until all // input and output processing has been done, and finally // closes the files and cleans up the Zlib structures. // void CStdCompress::CompressFile( const char *input, const char *output, int level ) { try { err = Z_OK; avail_in = 0; avail_out = output_length; next_out = output_buffer; m_AbortFlag = 0; fin = fopen( input, "rb" ); fout = fopen( output, "wb" ); length = filelength( fileno( fin ) ); deflateInit( this, level ); for ( ; ; ) { if ( m_AbortFlag ) break; if ( !load_input() ) break; err = deflate( this, Z_NO_FLUSH ); flush_output(); if ( err != Z_OK ) break; progress( percent() ); } for ( ; ; ) { if ( m_AbortFlag ) break; err = deflate( this, Z_FINISH ); if ( !flush_output() ) break; if ( err != Z_OK ) break; } progress( percent() ); deflateEnd( this ); if ( m_AbortFlag ) status( "User Abort" ); else if ( err != Z_OK && err != Z_STREAM_END ) status( "Zlib Error" ); else { status( "Success" ); err = Z_OK; } fclose( fin ); fclose( fout ); fin = 0; fout = 0; if(err != Z_OK && !m_AbortFlag) THROW_ERROR(Std_Err_ZLIB_lCompress, Std_Err_ZLIB_strCompress); } catch(CStdErrorInfo oError) {RELAY_ERROR(oError);} catch(...) {THROW_ERROR(Std_Err_ZLIB_lUnspecifiedError, Std_Err_ZLIB_strUnspecifiedError);} }
int stats_prepare_stats (struct connection *c) { stats_buffer_t sb; sb_prepare (&sb, c, stats_buff, STATS_BUFF_SIZE); sb_memory (&sb, AM_GET_MEMORY_USAGE_SELF + AM_GET_MEMORY_USAGE_OVERALL); SB_BINLOG; SB_INDEX; sb_printf (&sb, "snapshot_loading_average_blocking_read_bytes\t%.6f\n" "snapshot_loading_blocking_read_calls\t%d\n" "tot_user_metafiles\t%d\n" "tot_user_metafile_bytes\t%lld\n" "counters\t%d\n" "counters_percent\t%.6f\n" "counters_prime\t%d\n" "total_views\t%lld\n" "tree_nodes_allocated\t%d\n" "counter_instances\t%d\n" "counter_instances_percent\t%.6f\n" "allocated_counter_instances\t%d\n" "deleted_by_LRU\t%lld\n" "allocated_memory\t%lld\n" "tot_aio_queries\t%lld\n" "active_aio_queries\t%lld\n" "expired_aio_queries\t%lld\n" "avg_aio_query_time\t%.6f\n" "aio_bytes_loaded\t%lld\n" "tot_aio_queries\t%lld\n" "tot_aio_fails\t%lld\n" "memory_to_index\t%lld\n" "version\t%s\n", snapshot_loading_average_blocking_read_bytes, snapshot_loading_blocking_read_calls, tot_user_metafiles, tot_user_metafile_bytes, tot_counters, percent (tot_counters, max_counters), counters_prime, tot_views, alloc_tree_nodes, tot_counter_instances, percent (tot_counter_instances, index_size), tot_counters_allocated, deleted_by_lru, tot_memory_allocated, tot_aio_queries, active_aio_queries, expired_aio_queries, tot_aio_queries > 0 ? total_aio_time / tot_aio_queries : 0, tot_aio_loaded_bytes, tot_aio_queries, tot_aio_fails, memory_to_index, FullVersionStr ); return sb.pos; }
void printChromInfo(struct chromInfo *ci, FILE *f) /* Print out chromosome info. */ { fprintf(f, "%-5s %10u %8d %8d %6d %6d %6d %6d ", ci->name, ci->baseCount, ci->c50, ci->s50, ci->openCloneGaps, ci->bridgedCloneGaps, ci->openFragGaps, ci->bridgedFragGaps); if (stretch) fprintf(f, "%10d %4.1f %4.1f", ci->totalStretch, percent(ci->stretchedClones, ci->cloneCount), percent(ci->wayStretchedClones, ci->cloneCount)); fprintf(f, "\n"); }
void clientdbDump(StoreEntry * sentry) { ClientInfo *c; log_type l; int icp_total = 0; int icp_hits = 0; int http_total = 0; int http_hits = 0; storeAppendPrintf(sentry, "Cache Clients:\n"); hash_first(client_table); while ((c = (ClientInfo *) hash_next(client_table))) { storeAppendPrintf(sentry, "Address: %s\n", hashKeyStr(&c->hash)); storeAppendPrintf(sentry, "Name: %s\n", fqdnFromAddr(c->addr)); storeAppendPrintf(sentry, "Currently established connections: %d\n", c->n_established); storeAppendPrintf(sentry, " ICP Requests %d\n", c->Icp.n_requests); for (l = LOG_TAG_NONE; l < LOG_TYPE_MAX; l++) { if (c->Icp.result_hist[l] == 0) continue; icp_total += c->Icp.result_hist[l]; if (LOG_UDP_HIT == l) icp_hits += c->Icp.result_hist[l]; storeAppendPrintf(sentry, " %-20.20s %7d %3d%%\n", log_tags[l], c->Icp.result_hist[l], percent(c->Icp.result_hist[l], c->Icp.n_requests)); } storeAppendPrintf(sentry, " HTTP Requests %d\n", c->Http.n_requests); for (l = LOG_TAG_NONE; l < LOG_TYPE_MAX; l++) { if (c->Http.result_hist[l] == 0) continue; http_total += c->Http.result_hist[l]; if (isTcpHit(l)) http_hits += c->Http.result_hist[l]; storeAppendPrintf(sentry, " %-20.20s %7d %3d%%\n", log_tags[l], c->Http.result_hist[l], percent(c->Http.result_hist[l], c->Http.n_requests)); } storeAppendPrintf(sentry, "\n"); } storeAppendPrintf(sentry, "TOTALS\n"); storeAppendPrintf(sentry, "ICP : %d Queries, %d Hits (%3d%%)\n", icp_total, icp_hits, percent(icp_hits, icp_total)); storeAppendPrintf(sentry, "HTTP: %d Requests, %d Hits (%3d%%)\n", http_total, http_hits, percent(http_hits, http_total)); }
void tower(double r, double h) { int i; double h1, r1, angle, nx, ny, nz; onion(); diff(); cylinder(h, r, r * 0.85); cylinder(h, r * 0.85, r * 0.75); enddiff(); xlate(0, 0, h * 0.95); diff(); onion(); cylinder(h * 0.15, r * 0.85, r * 1.25); xlate(0, 0, h * 0.12); diff(); cylinder(h * 0.15, r * 1.25, r * 1.25); cylinder(h * 0.15 + 1, r * 0.95, r * 0.95); enddiff(); endxlate(); endonion(); xlate(0, 0, 0.25 * h); crenelation(h, r); endxlate(); enddiff(); endxlate(); for (i = 0; i < 5; i++) { angle = (360.0 * rand()) / RAND_MAX * 3.1415927 / 180.0; nx = cos(angle) * r * 0.85; ny = sin(angle) * r * 0.85; nz = 0.25 * h + (percent(55.0) * h); r1 = percent(40.0) * r; h1 = percent(50.0) * h; if (r1 < 5) continue; if (h1 < 20) continue; xlate(nx, ny, nz); tower(r1, h1); endxlate(); } xlate(0, 0, -h / 5.0); cylinder(h / 5.0, r * 0.1, r); endxlate(); endonion(); }
void storeDirStats(StoreEntry * sentry) { storeAppendPrintf(sentry, "Store Directory Statistics:\n"); storeAppendPrintf(sentry, "Store Entries : %d\n", memInUse(MEM_STOREENTRY)); storeAppendPrintf(sentry, "Maximum Swap Size : %8d KB\n", Config.Swap.maxSize); storeAppendPrintf(sentry, "Current Store Swap Size: %8d KB\n", store_swap_size); storeAppendPrintf(sentry, "Current Capacity : %d%% used, %d%% free\n", percent((int) store_swap_size, (int) Config.Swap.maxSize), percent((int) (Config.Swap.maxSize - store_swap_size), (int) Config.Swap.maxSize)); storeUfsDirStats(sentry); /* XXX */ }
QString RecvFile::transferStatsInfo() const { if (m_type == IPMSG_FILE_REGULAR) { QString bytesReadedString; if (m_size >= ONE_MB) { bytesReadedString = QString("%1") .arg(qMax(m_bytesReaded/ONE_MB, 0.1), 0, 'f', 1); } else { bytesReadedString = QString("%1") .arg(qMax(m_bytesReaded/ONE_KB, 1.0), 0, 'f', 0); } QString fileSizeString = bytesReadedString + "/" + Helper::sizeStringUnit(m_size); QString transferRateString = Helper::sizeStringUnit(transferRateAvg()) + "/s"; QString transferPercentString = QString("(%1%2)") .arg(percent(), 0, 'f', 0) .arg("%"); return (fileSizeString + " " + transferRateString + " " + transferPercentString); } else if (m_type == IPMSG_FILE_DIR) { return (QObject::tr("Total") + " " + Helper::sizeStringUnit((double)m_bytesReaded) + "/" + Helper::fileCountString(m_regularFileCount) + " (" + Helper::sizeStringUnit(transferRateAvg()) + "/s)"); } return QString(); }
void BeachScene::onUpdate(float deltaTime) { const OSize& frameSize = ODirector::director()->getVirtualSize(); float time = sin(ODirector::director()->getTimer()->getTime() / 1000.0); float p = percent(frameSize.width, 50); float st = sin(time); maths::vec2 position = wave1->getPosition(); wave1->setPosition(maths::vec2(-p/2.0f - st * WAVE_SPEED, 30 + st * WAVE_SPEED)); position = wave2->getPosition(); wave2->setPosition(maths::vec2(-p/2.0f + st * WAVE_SPEED, st * WAVE_SPEED)); position = wave3->getPosition(); wave3->setPosition(maths::vec2(-p/2.0f - st * WAVE_SPEED, -30 + st * WAVE_SPEED)); position = boat->getPosition(); boat->setPosition(maths::vec2(p + st * 60, 30 + sin(time * 2.5f) * WAVE_SPEED)); for (OSprite *cloud : clouds) { position = cloud->getPosition(); cloud->setPosition(maths::vec2(position.x + cloud->tag * deltaTime, position.y)); if (cloud->getPosition().x > frameSize.width) { cloud->setPosition(maths::vec2(- cloud->getSize().x, position.y)); } } }
main() { strcpy(status.nomefile,"base.idl"); inizializza(); setmenuP(0," Files ",1,hh); setmenuP(0," Compile ",1,menuto2); setmenuP(0," Quit! ",1,esci); setmenuS(0,1," Ciao ",1,hh); setmenuS(0,1," Addio ",1,gg); gwindow(60,60,300,200," Main Win ",12,1,14,3); num=status.active_window; perc_init(); for(x=0;x<=37;x++) { percent(x,37); } perc_end(); mouse(1); while(kd!=27) { while((kd=ikey())==0) {} controlla(kd); x=contr_drives(); if(x!=-1) {setdisk(x);dato=x;} } mouse(2); nogwin(); finisci(); return(0); }
void Print_Cache_Statistics_for_one_cache(CDS *cds) { fprintf(stdout, "%s: %d entries of lines of %d bytes; %s, %s, %s\n", cds->name, cds->number_of_cache_entries, cds->cache_line_size, print_sets_and_ways(cds), cds->write_back ? "write-back" : "write-thru", CRP_name(cds)); fprintf(stdout, " %d addresses (%d %s, %d %s, %d %s)\n", cds->number_of_memory_reference, cds->number_of_type[MAT_FETCH], memory_reference_type_name(MAT_FETCH), cds->number_of_type[MAT_LOAD], memory_reference_type_name(MAT_LOAD), cds->number_of_type[MAT_STORE], memory_reference_type_name(MAT_STORE)); fprintf(stdout, " %d hits (%d%%), %d misses, %d memory reads, %d memory writes\n", cds->number_cache_hits, percent(cds->number_cache_hits, cds->number_total_cache_access), cds->number_cache_misses, cds->number_memory_reads, cds->number_memory_writes); if (cds->write_back) fprintf(stdout, " %d dirty cache lines remain\n", number_dirty_lines(cds)); /* victim represents the # of victim cache entries. if you have a victim cache, this will be true. If not, victim = 0 and you do not have a victim cache. Thus, do not print out victim cache data */ if (cds->victim) fprintf(stdout, " %d victim cache hits\n", cds->number_victim_hits); fprintf(stdout, "\n"); }
string LongD(){ string ret = "This is a small device worn on the back and designed to \"boost\" " + "the wearer through the air or through space. For continuous operation, "+ "it should probably be activated. The fuel gauge "+ "reads "+to_int(percent(charge,maxcharge))+" percent."; return ret; }
string LongD(){ string ret = "This remarkably small device fits over the "+ "wearer's mouth, and provides a long supply of oxygenated "+ "air. Its current charge level is "+ to_int(percent(charge,maxcharge))+" percent."; return ret; }
string do_bar(int begin, int end) { int i, a; string st; st = "%^BOLD%^%^WHITE%^[%^RESET%^"; i = percent(begin, end); i += i; while(a<i) { if (a < 50) st += "%^GREEN%^%^BOLD%^"; if (a > 50) st += "%^YELLOW%^"; if (a > 120) st += "%^RED%^%^BOLD%^"; st += "|"; a += 10; } if (strlen(TERMINAL_D->no_colours(st)) < 21) while(strlen(TERMINAL_D->no_colours(st)) < 21) st += "%^BLACK%^%^BOLD%^.%^RESET%^"; st += "%^BOLD%^%^WHITE%^]%^RESET%^"; return st; }
void FileJob::setPercent(int pc) { if (pc!=progressPercent) { progressPercent=pc; emit percent(progressPercent); } }
/*! \brief \fn DoPercent \param arg \return double */ double DoPercent (double arg) { if (percent (static_cast <int> (arg))) // true x% of the time return 1.0; else return 0.0; }
void CleanJob::run() { int total=dirs.count(); int current=0; foreach (const QString &d, dirs) { if (stopRequested) { emit result(Device::Cancelled); return; } Device::cleanDir(d, base, coverFile); emit percent((++current*100)/total); } emit percent(100); emit result(Device::Ok); }
Dlist percents(const Dlist& L, double n) { Dlist Dl; for (int i=0; i<L.size(); i++) { Dl.push_back(percent(L[i],n)); } return Dl; }
static void gasmix(char *buffer, void *_fraction) { /* libdivecomputer does negative percentages. */ if (*buffer == '-') return; if (cylinder_index < MAX_CYLINDERS) percent(buffer, _fraction); }
static long pctdiffgraph(Stats *s, Stats *t, void *va) { Arg *a; a = va; return percent(t->n[a->index]-s->n[a->index], t->n[a->index2]-s->n[a->index2]); }
void FacebookJob::addPhoto(int code, const QString& message) { if(code==0 && !m_urls.isEmpty()) { int count = percent()+(100-percent())/m_urls.size(); KUrl url = m_urls.takeLast(); bool c = talk.addPhoto(url.toLocalFile(), m_albumId, url.fileName()); Q_ASSERT(c && "could not add the photo to the album"); //FIXME: Report error setPercent(count); } else { if(code!=0) { setError(code); setErrorText(message); } emitResult(); } }
static long pctgraph(Stats *s, Stats *t, void *va) { Arg *a; USED(s); a = va; return percent(t->n[a->index], t->n[a->index2]); }
void KJob::setPercent( unsigned long percentage ) { Q_D(KJob); if ( d->percentage!=percentage ) { d->percentage = percentage; emit percent( this, percentage ); } }
Private(HueSlider *widget) : w(widget) { w->setRange(0, 359); connect(w, &QSlider::valueChanged, [this]{ emit w->colorHueChanged(percent()); }); updateGradient(); }
//--------------------------------------------------------- // ReplicateStrategy //--------------------------------------------------------- int ReplicateStrategy::check(const ServerCollect* server_collect) const { int64_t count = get_ds_count(counter_, server_collect->get_ds()->id_); copy_count_ = percent(count, SYSPARAM_NAMESERVER.replicate_max_count_per_server_); if (count >= SYSPARAM_NAMESERVER.replicate_max_count_per_server_) return 0x00; return 0x01; }
void K3bThreadJob::customEvent( QCustomEvent* e ) { if( K3bDataEvent* de = dynamic_cast<K3bDataEvent*>(e) ) { emit data( de->data(), de->length() ); } else { K3bProgressInfoEvent* be = static_cast<K3bProgressInfoEvent*>(e); switch( be->type() ) { case K3bProgressInfoEvent::Progress: emit percent( be->firstValue() ); break; case K3bProgressInfoEvent::SubProgress: emit subPercent( be->firstValue() ); break; case K3bProgressInfoEvent::ProcessedSize: emit processedSize( be->firstValue(), be->secondValue() ); break; case K3bProgressInfoEvent::ProcessedSubSize: emit processedSubSize( be->firstValue(), be->secondValue() ); break; case K3bProgressInfoEvent::InfoMessage: emit infoMessage( be->firstString(), be->firstValue() ); break; case K3bProgressInfoEvent::Started: jobStarted(); break; case K3bProgressInfoEvent::Canceled: emit canceled(); break; case K3bProgressInfoEvent::Finished: // we wait until the thred really finished // although this may be dangerous if some thread // emits the finished signal although it has not finished yet // but makes a lot stuff easier. kdDebug() << "(K3bThreadJob) waiting for the thread to finish." << endl; m_thread->wait(); kdDebug() << "(K3bThreadJob) thread finished." << endl; cleanupJob( be->firstValue() ); m_running = false; jobFinished( be->firstValue() ); break; case K3bProgressInfoEvent::NewTask: emit newTask( be->firstString() ); break; case K3bProgressInfoEvent::NewSubTask: emit newSubTask( be->firstString() ); break; case K3bProgressInfoEvent::DebuggingOutput: emit debuggingOutput( be->firstString(), be->secondString() ); break; case K3bProgressInfoEvent::NextTrack: emit nextTrack( be->firstValue(), be->secondValue() ); break; } } }
void Wobbler::update () { // Scale from 0 to 6.28 every second position = percent () * M_PI * 2; // Scale -1/1 to 0/1 position = (sin(position) + 1) * 0.5; position *= amplitude; position += start_position; }
static void callback (void * dummy, const int * mus) { int remaining; const int * p; (void) dummy; remaining = 0; for (p = mus; *p; p++) remaining++; assert (remaining <= ngroups); msg ("<%d> reduction to %d out of %d (%.0f%%)", ++reductions, remaining, ngroups, percent (remaining, ngroups)); }
float parcelado(int num_de_parcelas, float valor) { float max_de_reducao = percent(15, valor, 1); if(valor/num_de_parcelas>=max_de_reducao) { return valor/num_de_parcelas; } else { return -1; } }