github.com/tomwright/dasel@v1.27.3/benchmark/run.sh (about) 1 outputFile="benchmark/README.md" 2 mdOutputFile="benchmark/tmp_results.md" 3 4 function run_file() { 5 counter=0 6 echo "## ${1}" >> "${outputFile}" 7 8 name="" 9 key="" 10 daselCmd="" 11 jqCmd="" 12 yqCmd="" 13 14 while IFS= read -r line 15 do 16 if [ "$line" == "END" ] 17 then 18 jsonFile="benchmark/data/${key}.json" 19 imagePath="benchmark/diagrams/${key}.jpg" 20 readmeImagePath="diagrams/${key}.jpg" 21 22 hyperfine --warmup 10 --runs 100 --export-json="${jsonFile}" --export-markdown="${mdOutputFile}" "${daselCmd}" "${jqCmd}" "${yqCmd}" 23 python benchmark/plot_barchart.py "${jsonFile}" --title "${name}" --out "${imagePath}" 24 25 echo "\n### ${name}\n" >> "${outputFile}" 26 echo "<img src=\"${readmeImagePath}\" alt=\"${name}\" width=\"500\"/>\n" >> "${outputFile}" 27 cat "${mdOutputFile}" >> "${outputFile}" 28 29 rm "${mdOutputFile}" 30 31 elif [ "$line" == "START" ] 32 then 33 counter=0 34 else 35 counter=$(($counter+1)) 36 case $counter in 37 1) name=$line 38 ;; 39 2) key=$line 40 ;; 41 3) daselCmd=$line 42 ;; 43 4) jqCmd=$line 44 ;; 45 5) yqCmd=$line 46 ;; 47 esac 48 fi 49 done < $2 50 } 51 52 rm -rf benchmark/data 53 rm -rf benchmark/diagrams 54 55 mkdir -p benchmark/data 56 mkdir -p benchmark/diagrams 57 58 cat benchmark/partials/top.md > "${outputFile}" 59 60 run_file "Benchmarks" "benchmark/tests.txt" 61 62 cat benchmark/partials/bottom.md >> "${outputFile}"