本文整理汇总了C++中percent函数的典型用法代码示例。如果您正苦于以下问题:C++ percent函数的具体用法?C++ percent怎么用?C++ percent使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了percent函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: spana_stats
/*
* 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 */
}
示例2: reviewSanity
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));
}
}
示例3: fopen
//
// 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);}
}
示例4: stats_prepare_stats
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;
}
示例5: printChromInfo
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");
}
示例6: clientdbDump
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));
}
示例7: tower
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();
}
示例8: storeDirStats
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 */
}
示例9: QString
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();
}
示例10: sin
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));
}
}
}
示例11: main
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);
}
示例12: Print_Cache_Statistics_for_one_cache
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");
}
示例13: LongD
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;
}
示例14: LongD
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;
}
示例15: do_bar
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;
}