void parser_t::emit_profiling(const char *path) const { /* Save profiling information. OK to not use CLO_EXEC here because this is called while fish is dying (and hence will not fork) */ FILE *f = fopen(path, "w"); if (!f) { debug(1, _(L"Could not write profiling information to file '%s'"), path); } else { if (fwprintf(f, _(L"Time\tSum\tCommand\n"), profile_items.size()) < 0) { wperror(L"fwprintf"); } else { print_profile(profile_items, f); } if (fclose(f)) { wperror(L"fclose"); } } }
void cmd_find(char *word) { int i; struct profile *p; char s[8]; char birthday_str[11]; int n=0; for(i = 0; i < profile_data_nitems; i++){ p = &profile_data_store[i]; sprintf(s,"%d",p->id); date_to_string(birthday_str,&p->birth); if(strcmp(s,word) == 0 || strcmp(p->name,word) == 0 || strcmp(birthday_str,word) == 0 || strcmp(p->home,word) == 0 || strcmp(p->comment,word) == 0){ print_profile(i,p); printf("\n"); }else{ n++; } } if(n = profile_data_nitems){ fprintf(stderr,"error: could not find\n\n"); } }
int main(void) { /* here are some profile records */ profile_list[0] = create_profile("Mrs", "Kydd", "1428-330 Fake Street", "Unit 1428", "Edmonton", "Alberta", "A1B2C3"); profile_list[1] = create_profile("Mr", "Kydd", "94 Fake Street", "Unit 505", "Edmonton", "Alberta", "A1B2C3"); profile_list[2] = create_profile("Mr", "Kydd", "43 Fake Street", "Unit 227", "Sherwood Park", "Alberta", "D4E5F6"); profile_list[3] = create_profile("Leeroy", "Jenkins", "1943 Fake Avenue", "Apt 123", "Sherwood Park", "Alberta", "D4E5F6"); /* sort the profiles */ (void)qsort(&profile_list, MAX_RECORDS, sizeof(struct profile *), profilecmp); /* print them out! */ int i = 0; for(i = 0; i < MAX_RECORDS; i++) { (void)print_profile(profile_list[i]); } /* free memory */ for(i = 0; i < MAX_RECORDS; i++) { (void)free_profile(profile_list[i]); } return 0; }
void cmd_print(int nitems) {//表示の範囲指定 int i, start = 0, end = profile_data_nitems; if (nitems > 0) end = print_min(nitems, profile_data_nitems); if (nitems < 0) start = print_max(end - (-nitems), 0); for (i = start; i < end; i++) { print_profile(&profile_data_store[i],i); printf("\n"); } }
void cmd_find(char *word) {//データの検索 int i, k = 0; for (i = 0; i < profile_data_nitems; i++){ if (find_strcmp(&profile_data_store[i], word) == 0){ print_profile(&profile_data_store[i], i); printf("\n"); k++; } } if (k == 0) printf("What match the search criteria was not found.\n"); }
static void exit_repl(int code) { exit_repl_environment(); if (have_color) { ios_printf(ios_stdout, jl_color_normal); ios_flush(ios_stdout); } #ifdef JL_GF_PROFILE print_profile(); #endif exit(code); }
void cmd_print(int nitems) { int i, start = 0, end = profile_data_nitems; if(nitems>0){ end = min(nitems,profile_data_nitems); } if(nitems<0){ start = max(end - (-nitems),0); } for(i = start; i < end; i++){ print_profile(i,&profile_data_store[i]); printf("\n\n"); } }
/* プリントコマンド(%P) **************************************************** */ void command_print (struct profile *p, int num, char *str) { int start = 0, end = nprofiles; int n; strcpy(str, ""); if (num > 0 && num < nprofiles) { end = num; } else if (num < 0 && num + end > 0) { start = num + end; } for (n = start; n < end; n++) { print_profile(&p[n], str); } }
void print_profile_box(double **x, char *outfile) { if (Proc == 0){ X_old = (double *) array_alloc (1, Nnodes*Nunk_per_node, sizeof(double)); Vext_old = (double *) array_alloc (1, Nnodes*Ncomp, sizeof(double)); } collect_x_old(x,X_old); collect_vext_old(); if (Proc==0) { print_profile(outfile,X_old); safe_free((void *) &X_old); safe_free((void *) &Vext_old); } }
/* Print information to given FILE* about statically set config options. */ void print_config(FILE* output) { fprintf(output, "Static option help:\n"); fprintf(output, "The default profile which is used is named default.\n"); // TODO: list toggle output array fprintf(output, "Sound profiles:\n"); const char* indent = " "; for (int i = 0; i < SOUND_PROFILES_SIZE; ++i) { print_profile(SOUND_PROFILES[i], indent, output); } if (USE_SEMAPHORE) fprintf(output, "Using semaphore named '%s' to prevent concurrent volume " "modification.\n", SEMAPHORE_NAME); }
/* 検索コマンド(%F) ******************************************************** */ void command_find (struct profile *p, char *keyword, char *str) { char id[8], birth[11]; int n; for (n = 0; n < nprofiles; n++) { make_id_string (p[n].id, id); make_birth_string (&p[n].birthday, birth); if (strcmp (id, keyword) == 0 || strcmp (birth, keyword) == 0 || strcmp (p[n].name, keyword) == 0 || strcmp (p[n].home, keyword) == 0) { print_profile (&p[n], str); printf ("\n"); } } }
int main(int argc, char *argv[]) { double duration; struct tms start, end; ATerm in_term, out_term; ATinit(argc, argv, &in_term); ATprotectArray(term_stack, TSIZE); ATprotectArray(environment, ESIZE); process_options(argc, argv); /* Open input file */ if (input_file == NULL) infile = stdin; else infile = fopen(input_file, "r"); /* Push term to be reduced on term stack */ if ((in_term = ATreadFromFile(infile)) == NULL) { ATfprintf(stderr, "not a valid term\n"); exit(1); } in_term = /*list_to_consnil*/(in_term); debugs(ATfprintf(stderr, "in_term (b) = %t\n", in_term)); /* Execute the strategy */ times(&start); out_term = doit(in_term); times(&end); duration = ((double)(end.tms_utime - start.tms_utime))/((double)CLK_TCK); if(out_term != NULL) { /* Open output file */ if (output_file == NULL) outfile = stdout; else outfile = fopen(output_file, "w"); /* ATfprintf(stdout, "%t\n", out_term); */ if(binary_output) ATwriteToBinaryFile(/*consnil_to_list*/(out_term), outfile); else ATwriteToTextFile(/*consnil_to_list*/(out_term), outfile); } print_profile(duration); if (!failed) { ATfprintf(stderr, " rewriting succeeded\n"); exit(0); } else { ATfprintf(stderr, " rewriting failed\n"); exit(1); } }
static void dump_video_param(AVCodecContext *avctx, QSVEncContext *q, mfxExtBuffer **coding_opts) { mfxInfoMFX *info = &q->param.mfx; mfxExtCodingOption *co = (mfxExtCodingOption*)coding_opts[0]; #if QSV_HAVE_CO2 mfxExtCodingOption2 *co2 = (mfxExtCodingOption2*)coding_opts[1]; #endif av_log(avctx, AV_LOG_VERBOSE, "profile: %s; level: %"PRIu16"\n", print_profile(info->CodecProfile), info->CodecLevel); av_log(avctx, AV_LOG_VERBOSE, "GopPicSize: %"PRIu16"; GopRefDist: %"PRIu16"; GopOptFlag: ", info->GopPicSize, info->GopRefDist); if (info->GopOptFlag & MFX_GOP_CLOSED) av_log(avctx, AV_LOG_VERBOSE, "closed "); if (info->GopOptFlag & MFX_GOP_STRICT) av_log(avctx, AV_LOG_VERBOSE, "strict "); av_log(avctx, AV_LOG_VERBOSE, "; IdrInterval: %"PRIu16"\n", info->IdrInterval); av_log(avctx, AV_LOG_VERBOSE, "TargetUsage: %"PRIu16"; RateControlMethod: %s\n", info->TargetUsage, print_ratecontrol(info->RateControlMethod)); if (info->RateControlMethod == MFX_RATECONTROL_CBR || info->RateControlMethod == MFX_RATECONTROL_VBR #if QSV_HAVE_VCM || info->RateControlMethod == MFX_RATECONTROL_VCM #endif ) { av_log(avctx, AV_LOG_VERBOSE, "BufferSizeInKB: %"PRIu16"; InitialDelayInKB: %"PRIu16"; TargetKbps: %"PRIu16"; MaxKbps: %"PRIu16"\n", info->BufferSizeInKB, info->InitialDelayInKB, info->TargetKbps, info->MaxKbps); } else if (info->RateControlMethod == MFX_RATECONTROL_CQP) { av_log(avctx, AV_LOG_VERBOSE, "QPI: %"PRIu16"; QPP: %"PRIu16"; QPB: %"PRIu16"\n", info->QPI, info->QPP, info->QPB); } #if QSV_HAVE_AVBR else if (info->RateControlMethod == MFX_RATECONTROL_AVBR) { av_log(avctx, AV_LOG_VERBOSE, "TargetKbps: %"PRIu16"; Accuracy: %"PRIu16"; Convergence: %"PRIu16"\n", info->TargetKbps, info->Accuracy, info->Convergence); } #endif #if QSV_HAVE_LA else if (info->RateControlMethod == MFX_RATECONTROL_LA #if QSV_HAVE_LA_HRD || info->RateControlMethod == MFX_RATECONTROL_LA_HRD #endif ) { av_log(avctx, AV_LOG_VERBOSE, "TargetKbps: %"PRIu16"; LookAheadDepth: %"PRIu16"\n", info->TargetKbps, co2->LookAheadDepth); } #endif #if QSV_HAVE_ICQ else if (info->RateControlMethod == MFX_RATECONTROL_ICQ) { av_log(avctx, AV_LOG_VERBOSE, "ICQQuality: %"PRIu16"\n", info->ICQQuality); } else if (info->RateControlMethod == MFX_RATECONTROL_LA_ICQ) { av_log(avctx, AV_LOG_VERBOSE, "ICQQuality: %"PRIu16"; LookAheadDepth: %"PRIu16"\n", info->ICQQuality, co2->LookAheadDepth); } #endif av_log(avctx, AV_LOG_VERBOSE, "NumSlice: %"PRIu16"; NumRefFrame: %"PRIu16"\n", info->NumSlice, info->NumRefFrame); av_log(avctx, AV_LOG_VERBOSE, "RateDistortionOpt: %s\n", print_threestate(co->RateDistortionOpt)); #if QSV_HAVE_CO2 av_log(avctx, AV_LOG_VERBOSE, "RecoveryPointSEI: %s IntRefType: %"PRIu16"; IntRefCycleSize: %"PRIu16"; IntRefQPDelta: %"PRId16"\n", print_threestate(co->RecoveryPointSEI), co2->IntRefType, co2->IntRefCycleSize, co2->IntRefQPDelta); av_log(avctx, AV_LOG_VERBOSE, "MaxFrameSize: %"PRIu16"; ", co2->MaxFrameSize); #if QSV_HAVE_MAX_SLICE_SIZE av_log(avctx, AV_LOG_VERBOSE, "MaxSliceSize: %"PRIu16"; ", co2->MaxSliceSize); #endif av_log(avctx, AV_LOG_VERBOSE, "\n"); av_log(avctx, AV_LOG_VERBOSE, "BitrateLimit: %s; MBBRC: %s; ExtBRC: %s\n", print_threestate(co2->BitrateLimit), print_threestate(co2->MBBRC), print_threestate(co2->ExtBRC)); #if QSV_HAVE_TRELLIS av_log(avctx, AV_LOG_VERBOSE, "Trellis: "); if (co2->Trellis & MFX_TRELLIS_OFF) { av_log(avctx, AV_LOG_VERBOSE, "off"); } else if (!co2->Trellis) { av_log(avctx, AV_LOG_VERBOSE, "auto"); } else { if (co2->Trellis & MFX_TRELLIS_I) av_log(avctx, AV_LOG_VERBOSE, "I"); if (co2->Trellis & MFX_TRELLIS_P) av_log(avctx, AV_LOG_VERBOSE, "P"); if (co2->Trellis & MFX_TRELLIS_B) av_log(avctx, AV_LOG_VERBOSE, "B"); } av_log(avctx, AV_LOG_VERBOSE, "\n"); #endif #if QSV_VERSION_ATLEAST(1, 8) av_log(avctx, AV_LOG_VERBOSE, "RepeatPPS: %s; NumMbPerSlice: %"PRIu16"; LookAheadDS: ", print_threestate(co2->RepeatPPS), co2->NumMbPerSlice); switch (co2->LookAheadDS) { case MFX_LOOKAHEAD_DS_OFF: av_log(avctx, AV_LOG_VERBOSE, "off"); break; case MFX_LOOKAHEAD_DS_2x: av_log(avctx, AV_LOG_VERBOSE, "2x"); break; case MFX_LOOKAHEAD_DS_4x: av_log(avctx, AV_LOG_VERBOSE, "4x"); break; default: av_log(avctx, AV_LOG_VERBOSE, "unknown"); break; } av_log(avctx, AV_LOG_VERBOSE, "\n"); av_log(avctx, AV_LOG_VERBOSE, "AdaptiveI: %s; AdaptiveB: %s; BRefType: ", print_threestate(co2->AdaptiveI), print_threestate(co2->AdaptiveB)); switch (co2->BRefType) { case MFX_B_REF_OFF: av_log(avctx, AV_LOG_VERBOSE, "off"); break; case MFX_B_REF_PYRAMID: av_log(avctx, AV_LOG_VERBOSE, "pyramid"); break; default: av_log(avctx, AV_LOG_VERBOSE, "auto"); break; } av_log(avctx, AV_LOG_VERBOSE, "\n"); #endif #if QSV_VERSION_ATLEAST(1, 9) av_log(avctx, AV_LOG_VERBOSE, "MinQPI: %"PRIu8"; MaxQPI: %"PRIu8"; MinQPP: %"PRIu8"; MaxQPP: %"PRIu8"; MinQPB: %"PRIu8"; MaxQPB: %"PRIu8"\n", co2->MinQPI, co2->MaxQPI, co2->MinQPP, co2->MaxQPP, co2->MinQPB, co2->MaxQPB); #endif #endif if (avctx->codec_id == AV_CODEC_ID_H264) { av_log(avctx, AV_LOG_VERBOSE, "Entropy coding: %s; MaxDecFrameBuffering: %"PRIu16"\n", co->CAVLC == MFX_CODINGOPTION_ON ? "CAVLC" : "CABAC", co->MaxDecFrameBuffering); av_log(avctx, AV_LOG_VERBOSE, "NalHrdConformance: %s; SingleSeiNalUnit: %s; VuiVclHrdParameters: %s VuiNalHrdParameters: %s\n", print_threestate(co->NalHrdConformance), print_threestate(co->SingleSeiNalUnit), print_threestate(co->VuiVclHrdParameters), print_threestate(co->VuiNalHrdParameters)); } av_log(avctx, AV_LOG_VERBOSE, "FrameRateExtD: %"PRIu32"; FrameRateExtN: %"PRIu32" \n", info->FrameInfo.FrameRateExtD, info->FrameInfo.FrameRateExtN); }
static void test_without_autorehash() { printf("========= fhash testing without auto rehash =========\n"); fhash_opt opt; opt.hash_alg = NULL; opt.compare = hash_core_compare; fhash* phash = fhash_create(0, opt, FHASH_MASK_NONE); // test set { unsigned long long start = ftime_gettime(); for (int i = 0; i < total_lines; i++) { fhash_set(phash, lines[i], (key_sz_t)strlen(lines[i]), lines[i], (value_sz_t)strlen(lines[i])); } unsigned long long end = ftime_gettime(); printf("fhash_set x%d spend time: %llu usec\n", total_lines, end - start); } // test get { unsigned long long start = ftime_gettime(); for (int i = 0; i < total_lines; i++) { fhash_get(phash, lines[i], (key_sz_t)strlen(lines[i]), NULL); } unsigned long long end = ftime_gettime(); printf("fhash_get x%d spend time: %llu usec\n", total_lines, end - start); } // test iteration { unsigned long long start = ftime_gettime(); fhash_iter iter = fhash_iter_new(phash); char* data = NULL; int iter_count = 0; while ((data = fhash_next(&iter))) { iter_count++; } fhash_iter_release(&iter); unsigned long long end = ftime_gettime(); printf("fhash_next x%d spend time: %llu usec\n", iter_count, end -start); } // test rehash { unsigned long long start = ftime_gettime(); int ret = fhash_rehash(phash, (uint32_t)total_lines); unsigned long long end = ftime_gettime(); printf("fhash_rehash (index double), ret: %d, spend time: %llu usec\n", ret, end -start); } fhash_profile_data profile_data; fhash_profile(phash, 0, &profile_data); print_profile(&profile_data); // test delete { unsigned long long start = ftime_gettime(); for (int i = 0; i < total_lines; i++) { fhash_del(phash, lines[i], (key_sz_t)strlen(lines[i])); } unsigned long long end = ftime_gettime(); printf("fhash_del x%d spend time: %llu usec\n", total_lines, end - start); } fhash_delete(phash); }