aboutsummaryrefslogtreecommitdiffstats
path: root/tests/compare-sizes.awk
blob: d294c54045e842f0b3c2c4834726d790ff730a16 (plain)
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
#!/usr/bin/awk -f
# Name: compare-sizes.awk
# Project: avr-usb
# Author: Christian Starkjohann
# Creation Date: 2008-04-29
# Tabsize: 4
# Copyright: (c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH
# License: GNU GPL v2 (see License.txt) or proprietary (CommercialLicense.txt)
# This Revision: $Id$

BEGIN{
	opt = 0;
	if(ARGC != 3){
		printf("usage: compare-sizes.awk file1 file2\n");
		printf("  computes size differences between two size lists\n");
		exit 1;
	}
	file1 = ARGV[1];
	file2 = ARGV[2];
}

{
	if(($2 + 0) != 0){
		if(!hadOption[$1]){
			hadOption[$1] = 1;
			options[opt++] = $1;
		}
		flash[FILENAME, $1] = $2;
		ram[FILENAME, $1] = $3;
	}
}

END{
	if(opt > 0){
		printf ("%39s %6s %5s\n", "Variation", "+Flash", "+RAM");
	}
	for(i = 0; i < opt; i++){
		option = options[i];
        if(!flash[file2, option] || !flash[file1, option]){
            printf("%39s %6s %5s\n", option, "n/a", "n/a");
        }else{
            printf("%39s %+6d %+5d\n", option, flash[file2, option] - flash[file1, option], ram[file2, option] - ram[file1, option]);
        }
	}
}