博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
测试运行批量【BAT】批量测试运行结果
阅读量:7132 次
发布时间:2019-06-28

本文共 4242 字,大约阅读时间需要 14 分钟。

最近使用开发的过程中出现了一个小问题,顺便记载一下原因和方法--测试运行批量

    经常用到批处理,但还是各种不熟。记载一些写的小文件,当前方便查询~

    

生成文件目录

    

将文件(及子文件下的图片)写入list.txt
@echo off&setlocal enabledelayedexpansionfor /r %%i in (*.jpg *.png *.tif) do (echo %%i >>list.txt)pause

测试文件,统计结果

    

使用test.exe测试list.txt中的文件,并记载结果,测试失败会输出“decoding failed”

    

@echo offset /a passed=0set /a all=0del /f /s /q result.txtfor %%p in (*.jpg *.png) do Release\test.exe %%p --more >>list.txtfor /f "delims=" %%i in (result.txt) do ( 	echo %%i	if not "%%i"=="decoding failed" set /a passed=passed+1	set /a all=all+1)echo %passed% passed in %all% pictures
test.exe 可以接受几种可选参数:
    每日一道理
生活中受伤难免,失败跌倒并不可怕,可怕的是因此而一蹶不振,失去了对人生的追求与远大的理想。没有一个人的前进道路是平平稳稳的,就算是河中穿梭航行的船只也难免颠簸,生活中所遇上的坎坷磨难不是偶尔给予的为难,而是必然所经受的磨练。
int main(int argc, char** argv) {  if (argc <= 1) {    cout << "Usage: " << argv[0] << " [OPTION]... ..." << endl         << "Read barcodes from each IMAGE file." << endl         << endl         << "Options:" << endl         << "  (-h|--hybrid)             use the hybrid binarizer (default)" << endl         << "  (-g|--global)             use the global binarizer" << endl         << "  (-v|--verbose)            chattier results printing" << endl         << "  --more                    display more information about the barcode" << endl         << "  --test-mode               compare IMAGEs against text files" << endl         << "  --try-harder              spend more time to try to find a barcode" << endl         << "  --search-multi            search for more than one bar code" << endl         << endl         << "Example usage:" << endl         << "  zxing --test-mode *.jpg" << endl         << endl;    return 1;  }  int total = 0;  int gonly = 0;  int honly = 0;  int both = 0;  int neither = 0;  for (int i = 1; i < argc; i++) {    string filename = argv[i];    if (filename.compare("--verbose") == 0 ||        filename.compare("-v") == 0) {      verbose = true;      continue;    }    if (filename.compare("--hybrid") == 0 ||        filename.compare("-h") == 0) {      use_hybrid = true;      continue;    }    if (filename.compare("--global") == 0 ||        filename.compare("-g") == 0) {      use_global = true;      continue;    }    if (filename.compare("--more") == 0) {      more = true;      continue;    }    if (filename.compare("--test-mode") == 0) {      test_mode = true;      continue;    }    if (filename.compare("--try-harder") == 0) {      try_harder = true;      continue;    }    if (filename.compare("--search-multi") == 0){      search_multi = true;      continue;    }    if (filename.length() > 3 &&        (filename.substr(filename.length() - 3, 3).compare("txt") == 0 ||         filename.substr(filename.length() - 3, 3).compare("bin") == 0)) {      continue;    }    if (!use_global && !use_hybrid) {      use_global = use_hybrid = true;    }    if (test_mode) {      cerr << "Testing: " << filename << endl;    }    Ref
source; try { source = ImageReaderSource::create(filename); } catch (const zxing::IllegalArgumentException &e) { cerr << e.what() << " (ignoring)" << endl; continue; } string expected = read_expected(filename); int gresult = 1; int hresult = 1; if (use_hybrid) { hresult = read_image(source, true, expected); } if (use_global && (verbose || hresult != 0)) { gresult = read_image(source, false, expected); if (!verbose && gresult != 0) { cout << "decoding failed" << endl; } } gresult = gresult == 0; hresult = hresult == 0; gonly += gresult && !hresult; honly += hresult && !gresult; both += gresult && hresult; neither += !gresult && !hresult; total = total + 1; } if (test_mode) { cout << endl << "Summary:" << endl << " " << total << " images tested total," << endl << " " << (honly + both) << " passed hybrid, " << (gonly + both) << " passed global, " << both << " pass both, " << endl << " " << honly << " passed only hybrid, " << gonly << " passed only global, " << neither << " pass neither." << endl; } return 0;}

(转载请注明作者和出处: 未经答应请勿用于商业用途)

文章结束给大家分享下程序员的一些笑话语录: 真正的程序员喜欢兼卖爆米花,他们利用CPU散发出的热量做爆米花,可以根据米花爆裂的速度听出正在运行什么程序。

--------------------------------- 原创文章 By

测试运行和批量
---------------------------------

你可能感兴趣的文章
MySQL必知必会
查看>>
Android窗口机制(五)最终章:WindowManager.LayoutParams和Token以及其他窗口Dialog,Toast...
查看>>
jquery瀑布流布局
查看>>
Nginx性能调优
查看>>
常见网络服务器开发开源项目代码规模
查看>>
它山之玉可以重构:身份证号(第四天)
查看>>
mysql问题解决
查看>>
IpuWadeMobile的Session管理
查看>>
ng alain-PC版的select组件在iphone的Safari浏览器带不出键盘----focus()使用
查看>>
hibernate 系列教程二:hibernate项目搭建
查看>>
内网渗透之socks5代理(reGeorg+proxifier详细配置说明)
查看>>
DHCP+tftp+pxe+kickstart自动安装Linux系统
查看>>
Spring bean循环依赖问题,与解决方案。
查看>>
android 技巧集锦
查看>>
利用JQuery的$.ajax()可以很方便的调用asp.net的后台方法。
查看>>
帝国备份王php5.4上出现500错误解决
查看>>
流媒体技术工程组
查看>>
shiro过滤器过滤属性含义
查看>>
iOS 隐藏导航栏UINavigationBar黑线
查看>>
A20总线
查看>>