📄 rf_genplot.c
字号:
j = l = strlen(argv[i]); kdevname = argv[i]; play_trace_init(); break; case 's': if (is_striper != (-1)) usage(); is_striper = 1; if (j+1 < l) usage(); i++; if (i >= targc) usage(); j = l = strlen(argv[i]); kdevname = argv[i]; play_trace_init(); break;#endif /* RF_CMU_PDL > 0 && !SIMULATE */ case 'n': nokey = 1; break; case 'o': doplot = 1; break; case 'p': doplot = 1; runscript = 0; break; default: fprintf(stderr, "Unknown option '%c'\n", argv[i][j]); usage(); } } } cl = fopen(configlist_filename, "r"); if (cl == NULL) { fprintf(stderr, "ERROR: cannot open %s\n", configlist_filename); exit(1); } while (tok = fgets(title, TITLELEN, cl)) { if (tok[0] == '#') continue; else break; } if (tok == NULL) { fprintf(stderr, "ERROR: cannot read title from %s\n", configlist_filename); exit(1); } while (tok = fgets(subtitle, TITLELEN, cl)) { if (tok[0] == '#') continue; else break; } if (tok == NULL) { fprintf(stderr, "ERROR: cannot read subtitle from %s\n", configlist_filename); exit(1); } title[TITLELEN-1] = subtitle[TITLELEN-1] = '\0'; title[strlen(title)-1] = '\0'; subtitle[strlen(subtitle)-1] = '\0'; while (tok = fgets(buf, LINE, cl)) { if (tok[0] == '#') continue; else break; } if (tok == NULL) { fprintf(stderr, "ERROR: cannot read axis ranges from %s\n", configlist_filename); exit(1); } if ((rc = sscanf(buf, "%lf %lf %lf %lf", &xmin, &xmax, &ymin, &ymax) != 4)) { fprintf(stderr, "ERROR: cannot read axis ranges from %s\n", configlist_filename); exit(1); } while (tok = fgets(buf, LINE, cl)) { if (tok[0] == '#') continue; else break; } if (tok == NULL) { fprintf(stderr, "ERROR: cannot read axis ranges from %s\n", configlist_filename); exit(1); } if ((rc = sscanf(buf, "%lf %lf %lf %lf", &xtickmajor, &xtickminor, &ytickmajor, &ytickminor) != 4)) { fprintf(stderr, "ERROR: cannot read axis ticks from %s\n", configlist_filename); exit(1); } ncfg = 0; line = 4; while(fgets(buf, LINE, cl)) { line++; buf[LINE-1] = '\0'; l = strlen(buf); if (buf[l-1] == '\n') { buf[l-1] = '\0'; l--; } if ((l == 0) || buf[0] == '#') continue; strcpy(buf2, buf); tok = strtok(buf2, ":"); if (tok == NULL) { fprintf(stderr, "ERROR processing line %d of %s (\"%s\")\n", line, configlist_filename, buf); exit(1); } cfg = get_plconfig(); strcpy(cfg->config_name, tok); tok = strtok(NULL, ""); if (tok == NULL) { fprintf(stderr, "ERROR processing line %d of %s (\"%s\")\n", line, configlist_filename, buf); exit(1); } strcpy(cfg->plot_name, tok); if (cfglistl) { cfglistl->next = cfg; cfglistl = cfg; } else { cfglist = cfglistl = cfg; } ncfg++; } if (ncfg == 0) { fprintf(stderr, "ERROR: no configs in %s\n", configlist_filename); exit(1); } if (ncfg > NUM_SYMS) { fprintf(stderr, "ERROR: %d configs, currently only support %d\n", ncfg, NUM_SYMS); exit(1); } wl = fopen(worklist_filename, "r"); if (wl == NULL) { fprintf(stderr, "ERROR: cannot open %s\n", worklist_filename); exit(1); } line = 0; while(fgets(buf, LINE, wl)) { line++; buf[LINE-1] = '\0'; l = strlen(buf); if (buf[l-1] == '\n') { buf[l-1] = '\0'; l--; } if ((l == 0) || buf[0] == '#') continue; wrk = get_workload(); strcpy(wrk->script_name, buf); if (wrklistl) { wrklistl->next = wrk; wrklistl = wrk; } else { wrklist = wrklistl = wrk; } } n = 0; for(cfg=cfglist;cfg;cfg=cfg->next) { for(wrk=wrklist;wrk;wrk=wrk->next) { l = 10 + strlen(cfg->plot_name) + strlen(cfg->config_name); n = RF_MAX(l,n); l = 10 + strlen(wrk->script_name); n = RF_MAX(l,n); } } if (runscript) { rc = unlink(out_filename); if (rc && (errno != ENOENT)) { perror("unlink"); fprintf(stderr, "ERROR: could not remove %s\n", out_filename); exit(1); } outf = fopen(out_filename, "w"); if (outf == NULL) { fprintf(stderr, "ERROR: could not open %s for writing\n", out_filename); exit(1); }#if RF_CMU_PDL > 0 && !defined(SIMULATE) if (kdevname) { rc = unlink(out_cpu_filename); if (rc && (errno != ENOENT)) { perror("unlink"); fprintf(stderr, "ERROR: could not remove %s\n", out_cpu_filename); exit(1); } outf_cpu = fopen(out_cpu_filename, "w"); if (outf_cpu == NULL) { fprintf(stderr, "ERROR: could not open %s for writing\n", out_cpu_filename); exit(1); } }#endif /* RF_CMU_PDL > 0 && !SIMULATE */ for(cfg=cfglist;cfg;cfg=cfg->next) { for(wrk=wrklist;wrk;wrk=wrk->next) { printf("\n\n\n"); for(i=0;i<n;i++) printf("-"); printf("\n"); printf("Config: %s (%s)\n", cfg->plot_name, cfg->config_name); printf("Workload: %s\n", wrk->script_name); for(i=0;i<n;i++) printf("-"); printf("\n"); fflush(stdout);#if RF_CMU_PDL > 0 && !defined(SIMULATE) if (kdevname) { if (is_striper) { sdo_run_script(cfg->config_name, wrk->script_name, &num_ios, &ios_per_sec, &response_time, &cpu_util); } else { kdo_run_script(cfg->config_name, wrk->script_name, &num_ios, &ios_per_sec, &response_time, &cpu_util); } } else { do_run_script(cfg->config_name, wrk->script_name, &num_ios, &ios_per_sec, &response_time); }#else /* RF_CMU_PDL > 0 && !SIMULATE */ do_run_script(cfg->config_name, wrk->script_name, &num_ios, &ios_per_sec, &response_time);#endif /* RF_CMU_PDL > 0 && !SIMULATE */ printf("Number of I/Os: %8lu\n", (unsigned long)num_ios); printf("I/Os per second: %8.2f\n", (float)ios_per_sec); printf("Avg response time: %8.2f\n", (float)response_time); fflush(stdout); fprintf(outf, "%8.2f %8.2f\n", (float)ios_per_sec, (float)response_time); fflush(outf);#if RF_CMU_PDL > 0 && !defined(SIMULATE) if (kdevname) { cpu_util *= (double)100.0; printf("CPU utilization : %8.2f\n", (float)cpu_util); fprintf(outf_cpu, "%8.2f %3.2f\n", (float)ios_per_sec, (float)cpu_util); fflush(outf_cpu); }#endif /* RF_CMU_PDL > 0 && !SIMULATE */ } fprintf(outf, "\n"); fflush(outf);#if RF_CMU_PDL > 0 && !defined(SIMULATE) if (kdevname) { fprintf(outf_cpu, "\n"); fflush(outf_cpu); }#endif /* RF_CMU_PDL > 0 && !SIMULATE */ } fclose(outf);#if RF_CMU_PDL > 0 && !defined(SIMULATE) if (kdevname) { fclose(outf_cpu); }#endif /* RF_CMU_PDL > 0 && !SIMULATE */ } if (doplot == 0) goto skip_plot; rc = unlink(out_ps_filename); if (rc && (errno != ENOENT)) { perror("unlink"); fprintf(stderr, "ERROR: could not remove %s\n", out_ps_filename); exit(1); } rc = unlink(out_mif_filename); if (rc && (errno != ENOENT)) { perror("unlink"); fprintf(stderr, "ERROR: could not remove %s\n", out_mif_filename); exit(1); } tmpnam(batch_filename); unlink(batch_filename); bf = fopen(batch_filename, "w"); if (bf == NULL) { fprintf(stderr, "ERROR: could not open temp file %s for writing\n", batch_filename); exit(1); } /* title */ fprintf(bf, "title \"%s\"\n", title); fprintf(bf, "title font 4\n"); fprintf(bf, "title size 1.500000\n"); fprintf(bf, "title color 1\n"); fprintf(bf, "title linewidth 1\n"); /* subtitle */ fprintf(bf, "subtitle \"%s\"\n", subtitle); fprintf(bf, "subtitle font 4\n"); fprintf(bf, "subtitle size 1.000000\n"); fprintf(bf, "subtitle color 1\n"); fprintf(bf, "subtitle linewidth 1\n"); /* axis */ fprintf(bf, "world xmin %lf\n", xmin); fprintf(bf, "world xmax %lf\n", xmax); fprintf(bf, "world ymin %lf\n", ymin); fprintf(bf, "world ymax %lf\n", ymax); fprintf(bf, "xaxis tick on\n"); fprintf(bf, "xaxis tick major %lf\n", xtickmajor); fprintf(bf, "xaxis tick minor %lf\n", xtickminor); fprintf(bf, "yaxis tick on\n"); fprintf(bf, "yaxis tick major %lf\n", ytickmajor); fprintf(bf, "yaxis tick minor %lf\n", ytickminor); fprintf(bf, "xaxis on\n"); if (nokey) fprintf(bf, "legend off\n"); else fprintf(bf, "legend on\n"); fprintf(bf, "xaxis label \"Throughput (IO/sec)\"\n"); fprintf(bf, "yaxis label \"Response time (ms)\"\n"); for(i=0,cfg=cfglist;i<ncfg;i++,cfg=cfg->next) { gs = &gsyms[i]; fprintf(bf, "s%d symbol %s\n", i, gs->symbol); fprintf(bf, "s%d symbol size %s\n", i, gs->symbol_size); fprintf(bf, "s%d fill %s\n", i, gs->symbol_fill); fprintf(bf, "s%d color %s\n", i, gs->color); fprintf(bf, "s%d linestyle %s\n", i, gs->linestyle); fprintf(bf, "legend string %d \"%s\"\n", i, cfg->plot_name); } /* postscript file */ fprintf(bf, "print to file \"%s\"\n", out_ps_filename); fprintf(bf, "hardcopy\n"); /* mif file */ fprintf(bf, "print to mifp\n"); fprintf(bf, "print to file \"%s\"\n", out_mif_filename); fprintf(bf, "hardcopy\n"); fprintf(bf, "exit\n"); fclose(bf); /* xmgr -portrait -hardcopy -batch batch_filename out_filename */ sprintf(cmd, "xmgr -portrait -hardcopy -batch %s %s", batch_filename, out_filename); system(cmd); unlink(batch_filename);#if RF_CMU_PDL > 0 && !defined(SIMULATE) if (kdevname == NULL) goto skip_plot; rc = unlink(out_cpu_ps_filename); if (rc && (errno != ENOENT)) { perror("unlink"); fprintf(stderr, "ERROR: could not remove %s\n", out_cpu_ps_filename); exit(1); } rc = unlink(out_cpu_mif_filename); if (rc && (errno != ENOENT)) { perror("unlink"); fprintf(stderr, "ERROR: could not remove %s\n", out_cpu_mif_filename); exit(1); } tmpnam(batch_filename); unlink(batch_filename); bf = fopen(batch_filename, "w"); if (bf == NULL) { fprintf(stderr, "ERROR: could not open temp file %s for writing\n", batch_filename); exit(1); } /* title */ fprintf(bf, "title \"%s\"\n", title); fprintf(bf, "title font 4\n"); fprintf(bf, "title size 1.500000\n"); fprintf(bf, "title color 1\n"); fprintf(bf, "title linewidth 1\n"); /* subtitle */ fprintf(bf, "subtitle \"%s (CPU utilization)\"\n", subtitle); fprintf(bf, "subtitle font 4\n"); fprintf(bf, "subtitle size 1.000000\n"); fprintf(bf, "subtitle color 1\n"); fprintf(bf, "subtitle linewidth 1\n"); /* axis */ fprintf(bf, "world xmin %lf\n", xmin); fprintf(bf, "world xmax %lf\n", xmax); fprintf(bf, "world ymin 0.00\n"); fprintf(bf, "world ymax 100.00\n"); fprintf(bf, "xaxis tick on\n"); fprintf(bf, "xaxis tick major %lf\n", xtickmajor); fprintf(bf, "xaxis tick minor %lf\n", xtickminor); fprintf(bf, "yaxis tick on\n"); fprintf(bf, "yaxis tick major 10.0\n"); fprintf(bf, "yaxis tick minor 5.0\n"); fprintf(bf, "xaxis on\n"); if (nokey) fprintf(bf, "legend off\n"); else fprintf(bf, "legend on\n"); fprintf(bf, "xaxis label \"Throughput (IO/sec)\"\n"); fprintf(bf, "yaxis label \"CPU utilization (%%)\"\n"); for(i=0,cfg=cfglist;i<ncfg;i++,cfg=cfg->next) { gs = &gsyms[i]; fprintf(bf, "s%d symbol %s\n", i, gs->symbol); fprintf(bf, "s%d symbol size %s\n", i, gs->symbol_size); fprintf(bf, "s%d fill %s\n", i, gs->symbol_fill); fprintf(bf, "s%d color %s\n", i, gs->color); fprintf(bf, "s%d linestyle %s\n", i, gs->linestyle); fprintf(bf, "legend string %d \"%s\"\n", i, cfg->plot_name); } /* postscript file */ fprintf(bf, "print to file \"%s\"\n", out_cpu_ps_filename); fprintf(bf, "hardcopy\n"); /* mif file */ fprintf(bf, "print to mifp\n"); fprintf(bf, "print to file \"%s\"\n", out_cpu_mif_filename); fprintf(bf, "hardcopy\n"); fprintf(bf, "exit\n"); fclose(bf); /* xmgr -portrait -hardcopy -batch batch_filename out_filename */ sprintf(cmd, "xmgr -portrait -hardcopy -batch %s %s", batch_filename, out_cpu_filename); system(cmd); unlink(batch_filename);#endif /* RF_CMU_PDL > 0 && !SIMULATE */skip_plot: exit(0);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -