File: extractor.awk

package info (click to toggle)
coccinelle 1.0.8.deb-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 26,148 kB
  • sloc: ml: 136,392; ansic: 23,594; sh: 2,189; makefile: 2,157; perl: 1,576; lisp: 840; python: 823; awk: 70; csh: 12
file content (94 lines) | stat: -rwxr-xr-x 2,602 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/awk -f
#
# Extracting time statistics from .failed/.ok files
#

BEGIN {
  no_of_files = 0;
  max_running_time = 0.0;
  max_running_file = "";
  min_running_time = 100000.0;
  min_running_file = "";
  sum_running_time = 0.0;

  min_file_size_lines = 0;
  max_file_size_lines = 0;
  tot_file_size_lines = 0;
  min_file_size_bytes = 0;
  max_file_size_bytes = 0;
  tot_file_size_bytes = 0;
}
/real[ \t]+[0-9]+m[0-9]+[.][0-9]+/{

  # The file currently processed
  current_file = FILENAME;

  # Count the number of files
  no_of_files++;

  # Parse time field
  split($2,timearr,/[m.]/);
  current_time = timearr[1] * 60.0;   # minutes
  current_time += timearr[2];         # seconds
  current_time += timearr[3] / 1000.0; # 1/1000th sec.

  # Print progress
  printf "%6.3fs (%s)\n", current_time, current_file;

  # Update total time
  sum_running_time += current_time;

  # Update max and min
  if(current_time > max_running_time)
    {
      max_running_time = current_time;
      max_running_file = current_file;
    }
  if(current_time < min_running_time)
    {
      min_running_time = current_time;
      min_running_file = current_file;
    }

  # Find corresponding .c file
  gsub(/.(ok|failed|spatch_ok|gave_up)$/,".c",current_file);

  # Update file sizes (in lines)
  ("wc -l " current_file) | getline;
  current_size_lines = $1;
  tot_file_size_lines += current_size_lines;
  if(current_size_lines > max_file_size_lines)
    {
      max_file_size_lines = current_size_lines;
    }
  if(current_size_lines < min_file_size_lines)
    {
      min_file_size_lines = current_size_lines;
    }

  # Update file sizes (in bytes)
  ("du " current_file) | getline;
  current_size_bytes = $1;
  tot_file_size_bytes += current_size_bytes;
  if(current_size_bytes > max_file_size_bytes)
    {
      max_file_size_lines = current_size_bytes;
    }
  if(current_size_bytes < min_file_size_bytes)
    {
      min_file_size_bytes = current_size_bytes;
    }
}
END {
  printf "!!No. of files    : %6d\n", no_of_files;
  printf "  Total # of lines: %6d\n", tot_file_size_lines;
  printf "!!Avg. # of lines : %9.2f\n", (tot_file_size_lines / no_of_files);
  printf "  Total size (KB) : %6d\n", tot_file_size_bytes;
  printf "  Avg. size (KB)  : %9.2f\n", (tot_file_size_bytes / no_of_files);
  printf "  Minimum time    : %9.2fs (%s)\n",
    min_running_time, min_running_file;
  printf "!!Maximum time    : %9.2fs (%s)\n",
    max_running_time, max_running_file;
  printf "  Total time      : %9.2fs\n", sum_running_time;
  printf "!!Average time    : %9.2fs\n", (sum_running_time / no_of_files);
}