2010-6-23 Report File Output功能追加

作者在解决跨域问题的同时,临时处理了一个VBA程序的功能追加问题。通过4小时的努力,成功实现了文件输出的循环功能并修复了一个与日期相关的bug。

昨天下午本来就因为调查跨域(Crossing Domain)传值的问题而暂时中断了Ruby on Rails。
而今天上午跨域的问题还没弄完,又半途因为以前做的一个VBA的程序功能追加的紧急对应而陷入了中断的中断。。
我提出的预算是4个小时。而实际上,从11点着手,在中午12点前就大致完成了。
很简单的一个功能,就是在原来文件输出的基础上,加入循环,输出多个工作表。
下午调试修改。然后发现了以前的一个bug。
用6月份的报表读入数据后输出时,由于数据项总是为31,而6月份的数据只有30条,所以取第31条数据时就发生错误。
难道我以前测试是用天数31天的月表报测试的??汗颜,测试不足。。。
用到的方法如下:
dayOfMonth = Day(DateSerial(CInt(year), CInt(Format(month, "0")) + 1, 0))
year和month为字符串类型,需要用CInt转换成整形,并且month为“06”形式的,需要用Format函数除去前头的0。
CInt函数居然不能直接把“06”转换成6,出乎意料。
到此完成。
经验证,修正意见无。好玩的是leader点着文件名为“Book23”的输出文件说,真有意思的名字啊。
我小汗了一下,说因为程序中没有指定文件名,所以是Excel默认的名字,不断递增。
呃。。以前问过然后说输出文件名不需要指定才会这样的嘛,嗯,从这数字上看,我搞完这个功能的时候一共测试了22次!

接下来继续跨域~

sh fio-new.sh No job(s) defined fio-3.19 fio [options] [job options] <job file(s)> --debug=options Enable debug logging. May be one/more of: process,file,io,mem,blktrace,verify,random,parse, diskutil,job,mutex,profile,time,net,rate,compress, steadystate,helperthread,zbd --parse-only Parse options only, don't start any IO --merge-blktrace-only Merge blktraces only, don't start any IO --output Write output to file --bandwidth-log Generate aggregate bandwidth logs --minimal Minimal (terse) output --output-format=type Output format (terse,json,json+,normal) --terse-version=type Set terse version output format (default 3, or 2 or 4) --version Print version info and exit --help Print this page --cpuclock-test Perform test/validation of CPU clock --crctest=[type] Test speed of checksum functions --cmdhelp=cmd Print command help, "all" for all of them --enghelp=engine Print ioengine help, or list available ioengines --enghelp=engine,cmd Print help for an ioengine cmd --showcmd Turn a job file into command line options --eta=when When ETA estimate should be printed May be "always", "never" or "auto" --eta-newline=t Force a new line for every 't' period passed --status-interval=t Force full status dump every 't' period passed --readonly Turn on safety read-only checks, preventing writes --section=name Only run specified section in job file, multiple sections can be specified --alloc-size=kb Set smalloc pool to this size in kb (def 16384) --warnings-fatal Fio parser warnings are fatal --max-jobs=nr Maximum number of threads/processes to support --server=args Start a backend fio server --daemonize=pidfile Background fio server, write pid to file --client=hostname Talk to remote backend(s) fio server at hostname --remote-config=file Tell fio server to load this local job file --idle-prof=option Report cpu idleness on a system or percpu basis (option=system,percpu) or run unit work calibration only (option=calibrate) --inflate-log=log Inflate and output compressed log --trigger-file=file Execute trigger cmd when file exists --trigger-timeout=t Execute trigger at this time --trigger=cmd Set this command as local trigger --trigger-remote=cmd Set this command as remote trigger --aux-path=path Use this path for fio state generated files Fio was written by Jens Axboe <axboe@kernel.dk> fio-new.sh: line 15: --verify_dump=1: command not found
05-23
#!/bin/bash # 磁盘性能测试脚本 - 增强版 # 功能测试sdb和sdc的顺序/随机读写性能,并生成性能指标报告 # 设置变量 DISKS=("/dev/sdb" "/dev/sdc") TEST_TYPES=("randread" "randwrite" "read" "write") LOG_DIR="./fio_logs" REPORT_FILE="./performance_report.log" RUNTIME=600 RAMP_TIME=40 # 创建日志目录 mkdir -p $LOG_DIR # 函数:提取性能指标并保存到报告 extract_performance_metrics() { local log_file=$1 local disk_name=$2 local test_type=$3 echo "======= 性能指标: $disk_name - $test_type =======" >> $REPORT_FILE if [ ! -f "$log_file" ]; then echo "错误: 日志文件不存在" >> $REPORT_FILE echo "" >> $REPORT_FILE return fi # 检查是否为JSON格式 if grep -q "^{" "$log_file"; then # JSON格式处理 local iops=$(grep -o '"iops":[^,]*' "$log_file" | head -1 | cut -d: -f2 | tr -d ' ' || echo "N/A") local bw=$(grep -o '"bw":[^,]*' "$log_file" | head -1 | cut -d: -f2 | tr -d ' ' || echo "N/A") local lat=$(grep -o '"mean":[^,]*' "$log_file" | head -1 | cut -d: -f2 | tr -d ' ' || echo "N/A") # 如果有lat值,转换为毫秒 if [[ "$lat" =~ ^[0-9]+$ ]] && [ "$lat" != "N/A" ]; then lat=$(echo "scale=2; $lat / 1000000" | bc 2>/dev/null || echo "$lat ns") fi echo "IOPS: $iops" >> $REPORT_FILE echo "带宽: $bw KB/s" >> $REPORT_FILE echo "平均延迟: $lat ms" >> $REPORT_FILE else # 文本格式处理 local iops=$(grep -E "IOPS=[0-9]" "$log_file" | grep -o "IOPS=[0-9.]*" | cut -d= -f2 | head -1 || echo "N/A") local bw=$(grep -E "BW=[0-9]" "$log_file" | grep -o "BW=[0-9.]*[KM]iB" | cut -d= -f2 | head -1 || echo "N/A") local lat=$(grep -E "lat.*avg" "$log_file" | grep -o "avg=[0-9.]*" | cut -d= -f2 | head -1 || echo "N/A") echo "IOPS: $iops" >> $REPORT_FILE echo "带宽: $bw" >> $REPORT_FILE echo "平均延迟: $lat ms" >> $REPORT_FILE # 提取延迟百分位信息 grep -A5 "clat percentiles" "$log_file" >> $REPORT_FILE 2>/dev/null fi echo "" >> $REPORT_FILE } # 函数:执行fio测试 run_fio_test() { local disk=$1 local test_type=$2 local disk_name=$(basename $disk) local output_file="${LOG_DIR}/${disk_name}_${test_type}.log" echo "$(date): 开始测试 $disk - $test_type" case $test_type in "randread") fio --filename=$disk --rw=randread --bs=4k --numjobs=4 --iodepth=32 \ --runtime=$RUNTIME --time_based=1 --stonewall --ramp_time=$RAMP_TIME \ --direct=1 --ioengine=libaio --norandommap=1 --randrepeat=0 \ --group_reporting \ --output=$output_file --name=randread --output-format=json ;; "randwrite") fio --filename=$disk --rw=randwrite --bs=4k --numjobs=4 --iodepth=32 \ --runtime=$RUNTIME --time_based=1 --stonewall --ramp_time=$RAMP_TIME \ --direct=1 --ioengine=libaio --norandommap=1 --randrepeat=0 \ --group_reporting \ --output=$output_file --name=randwrite --output-format=json ;; "read") fio --filename=$disk --rw=read --bs=1M --numjobs=1 --iodepth=64 \ --runtime=$RUNTIME --time_based=1 --stonewall --ramp_time=$RAMP_TIME \ --direct=1 --ioengine=libaio --norandommap=1 --randrepeat=0 \ --group_reporting \ --output=$output_file --name=read --output-format=json ;; "write") fio --filename=$disk --rw=write --bs=1M --numjobs=1 --iodepth=64 \ --runtime=$RUNTIME --time_based=1 --stonewall --ramp_time=$RAMP_TIME \ --direct=1 --ioengine=libaio --norandommap=1 --randrepeat=0 \ --group_reporting \ --output=$output_file --name=write --output-format=json ;; esac # 检查测试是否成功并提取指标 if [ $? -eq 0 ]; then echo "$(date): ✓ 测试完成: $output_file" # 提取性能指标到报告 extract_performance_metrics "$output_file" "$disk_name" "$test_type" else echo "$(date): ✗ 测试失败: $test_type on $disk" echo "======= 性能指标: $disk_name - $test_type =======" >> $REPORT_FILE echo "测试失败" >> $REPORT_FILE echo "" >> $REPORT_FILE fi echo "----------------------------------------" } # 函数:显示测试进度 show_progress() { local current=$1 local total=$2 local percent=$((current * 100 / total)) echo "进度: [$current/$total] $percent%" } # 函数:生成报告头部 generate_report_header() { echo "========================================" > $REPORT_FILE echo " 磁盘性能测试报告" >> $REPORT_FILE echo "生成时间: $(date)" >> $REPORT_FILE echo "测试磁盘: ${DISKS[@]}" >> $REPORT_FILE echo "测试类型: ${TEST_TYPES[@]}" >> $REPORT_FILE echo "运行时长: ${RUNTIME}秒" >> $REPORT_FILE echo "========================================" >> $REPORT_FILE echo "" >> $REPORT_FILE } # 函数:生成报告摘要 generate_report_summary() { echo "" >> $REPORT_FILE echo "========================================" >> $REPORT_FILE echo " 测试摘要" >> $REPORT_FILE echo "========================================" >> $REPORT_FILE echo "总测试数: $((${#DISKS[@]} * ${#TEST_TYPES[@]}))" >> $REPORT_FILE echo "开始时间: $start_time" >> $REPORT_FILE echo "结束时间: $(date)" >> $REPORT_FILE echo "日志目录: $LOG_DIR" >> $REPORT_FILE echo "报告文件: $REPORT_FILE" >> $REPORT_FILE echo "========================================" >> $REPORT_FILE } # 主函数 main() { local start_time=$(date) echo "========================================" echo " 磁盘性能测试开始" echo " 测试磁盘: ${DISKS[@]}" echo " 测试类型: ${TEST_TYPES[@]}" echo " 日志目录: $LOG_DIR" echo " 报告文件: $REPORT_FILE" echo "========================================" # 初始化报告文件 generate_report_header # 检查fio是否安装 if ! command -v fio &> /dev/null; then echo "错误: fio 未安装,请先安装fio" echo "错误: fio 未安装" >> $REPORT_FILE exit 1 fi # 检查磁盘是否存在 for disk in "${DISKS[@]}"; do if [ ! -e "$disk" ]; then echo "错误: 磁盘 $disk 不存在" echo "错误: 磁盘 $disk 不存在" >> $REPORT_FILE exit 1 fi done local total_tests=$((${#DISKS[@]} * ${#TEST_TYPES[@]})) local current_test=0 # 执行测试 for disk in "${DISKS[@]}"; do echo "正在测试磁盘: $disk" echo "磁盘: $(basename $disk)" >> $REPORT_FILE for test_type in "${TEST_TYPES[@]}"; do current_test=$((current_test + 1)) show_progress $current_test $total_tests run_fio_test $disk $test_type done echo "磁盘 $disk 测试完成" echo "========================================" done # 生成报告摘要 generate_report_summary echo "所有测试完成!" echo "详细日志保存在: $LOG_DIR" echo "性能指标报告: $REPORT_FILE" # 显示报告文件内容预览 echo "" echo "性能报告预览:" echo "========================================" head -20 $REPORT_FILE echo "..." echo "完整报告请查看: $REPORT_FILE" } # 执行主函数 main 📈 配套的性能分析脚本:analyze_performance.sh bash #!/bin/bash # 性能分析脚本 # 用于从fio JSON日志中提取详细性能指标 LOG_DIR="./fio_logs" DETAILED_REPORT="./detailed_performance_analysis.log" echo "开始分析性能数据..." echo "详细性能分析报告" > $DETAILED_REPORT echo "生成时间: $(date)" >> $DETAILED_REPORT echo "==========================================" >> $DETAILED_REPORT for log_file in $LOG_DIR/*.json; do if [ -f "$log_file" ]; then disk_test=$(basename "$log_file" .json) echo "分析: $disk_test" >> $DETAILED_REPORT echo "------------------------------------------" >> $DETAILED_REPORT # 使用jq提取详细指标(如果可用) if command -v jq &> /dev/null; then jq -r '.jobs[0] | { read_iops: (.read?.iops // 0), write_iops: (.write?.iops // 0), read_bw: (.read?.bw // 0), write_bw: (.write?.bw // 0), read_lat: (.read?.lat_ns?.mean // 0), write_lat: (.write?.lat_ns?.mean // 0) } | "IOPS(读/写): \(.read_iops)/\(.write_iops)\n带宽(读/写): \(.read_bw)/\(.write_bw) KB/s\n延迟(读/写): \(.read_lat/1000000)/\(.write_lat/1000000) ms"' "$log_file" >> $DETAILED_REPORT 2>/dev/null else echo "需要jq工具来解析JSON日志" >> $DETAILED_REPORT echo "安装命令: yum install jq 或 apt-get install jq" >> $DETAILED_REPORT fi echo "" >> $DETAILED_REPORT fi done echo "详细分析完成: $DETAILED_REPORT"。。。。完善脚本,去掉没必要的命令,完善性能分析脚本结果为空的performance report.log的命令
10-14
PS D:\yipule\currentPro\calculate> npx eslint eslint [options] file.js [file.js] [dir] Basic configuration: --no-eslintrc Disable use of configuration from .eslintrc.* -c, --config path::String Use this configuration, overriding .eslintrc.* config options if present --env [String] Specify environments --ext [String] Specify JavaScript file extensions - default: .js --global [String] Define global variables --parser String Specify the parser to be used --parser-options Object Specify parser options --resolve-plugins-relative-to path::String A folder where plugins should be resolved from, CWD by default Specifying rules and plugins: --rulesdir [path::String] Use additional rules from this directory --plugin [String] Specify plugins --rule Object Specify rules Fixing problems: --fix Automatically fix problems --fix-dry-run Automatically fix problems without saving the changes to the file system --fix-type Array Specify the types of fixes to apply (problem, suggestion, layout) Ignoring files: --ignore-path path::String Specify path of ignore file --no-ignore Disable use of ignore files and patterns --ignore-pattern [String] Pattern of files to ignore (in addition to those in .eslintignore) Using stdin: --stdin Lint code provided on <STDIN> - default: false --stdin-filename String Specify filename to process STDIN as Handling warnings: --quiet Report errors only - default: false --max-warnings Int Number of warnings to trigger nonzero exit code - default: -1 Output: -o, --output-file path::String Specify file to write report to -f, --format String Use a specific output format - default: stylish --color, --no-color Force enabling/disabling of color Inline configuration comments: --no-inline-config Prevent comments from changing config or rules --report-unused-disable-directives Adds reported errors for unused eslint-disable directives Caching: --cache Only check changed files - default: false --cache-file path::String Path to the cache file. Deprecated: use --cache-location - default: .eslintcache --cache-location path::String Path to the cache file or directory Miscellaneous: --init Run config initialization wizard - default: false --env-info Output execution environment information - default: false --debug Output debugging information -h, --help Show help -v, --version Output the version number --print-config path::String Print the configuration for the given file
05-23
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值