report.awk (2826B)
1 #!/usr/bin/awk -f 2 # 3 # Copyright (c) 2016, 2017 Kyle Milz <kyle@0x30.net> 4 # 5 # Permission to use, copy, modify, and distribute this software for any 6 # purpose with or without fee is hereby granted, provided that the above 7 # copyright notice and this permission notice appear in all copies. 8 # 9 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 # 17 # Counts events in citrun.log files. 18 # 19 $0~/>> citrun_inst/ { summary[0] += 1 } 20 $0~/Found source file/ { summary[1] += 1 } 21 $0~/Link detected/ { summary[2] += 1 } 22 $0~/Rewritten source compile successfu/ { summary[3] += 1 } 23 $0~/Rewritten source compile failed/ { summary[4] += 1 } 24 25 $0~/Lines of source code/ { totals[0] += $2 } 26 $0~/Milliseconds spent rewriting sourc/ { totals[1] += $2 } 27 $0~/Function definitions/ { totals[2] += $2 } 28 $0~/If statements/ { totals[3] += $2 } 29 $0~/For loops/ { totals[4] += $2 } 30 $0~/While loops/ { totals[5] += $2 } 31 $0~/Do while loops/ { totals[6] += $2 } 32 $0~/Switch statements/ { totals[7] += $2 } 33 $0~/Return statement values/ { totals[8] += $2 } 34 $0~/Call expressions/ { totals[9] += $2 } 35 $0~/Total statements/ { totals[10] += $2 } 36 $0~/Binary operators/ { totals[11] += $2 } 37 $0~/Errors rewriting source/ { totals[12] += $2 } 38 39 END { 40 if (summary[0] == 0) { 41 print "No signs of rewrite activity. Are any of the arguments log files?" 42 exit 1 43 } 44 45 summary_desc[0] = "Rewrite tool runs" 46 summary_desc[1] = "Source files used as input" 47 summary_desc[2] = "Application link commands" 48 summary_desc[3] = "Successful modified source compiles" 49 summary_desc[4] = "Failed modified source compiles" 50 51 print "Summary:" 52 for (i = 0; i < 5; i++) { 53 if (summary[i] == 0) continue 54 printf "%10i %s\n", summary[i], summary_desc[i] 55 } 56 57 totals_desc[0] = "Lines of source code" 58 totals_desc[1] = "Milliseconds spent rewriting source" 59 totals_desc[2] = "Function definitions" 60 totals_desc[3] = "If statements" 61 totals_desc[4] = "For loops" 62 totals_desc[5] = "While loops" 63 totals_desc[6] = "Do while loops" 64 totals_desc[7] = "Switch statements" 65 totals_desc[8] = "Return statement values" 66 totals_desc[9] = "Call expressions" 67 totals_desc[10] = "Total statements" 68 totals_desc[11] = "Binary operators" 69 totals_desc[12] = "Errors rewriting source" 70 71 print "" 72 print "Totals:" 73 for (i = 0; i < 13; i++) { 74 if (i != 0 && totals[i] == 0) continue 75 printf "%10i %s\n", totals[i], totals_desc[i] 76 } 77 }