1 | // EvalStats.cpp : Defines the entry point for the console application.
|
---|
2 | //
|
---|
3 | #include "stdafx.h"
|
---|
4 |
|
---|
5 | #include <string>
|
---|
6 | #include <vector>
|
---|
7 | #include <istream>
|
---|
8 | #include <iostream>
|
---|
9 | #include <fstream>
|
---|
10 |
|
---|
11 |
|
---|
12 | using namespace std;
|
---|
13 |
|
---|
14 | bool extractRenderCost(ifstream &file, vector<float> &renderCosts)
|
---|
15 | {
|
---|
16 | if (!file.is_open())
|
---|
17 | return false;
|
---|
18 |
|
---|
19 | string buf;
|
---|
20 | bool isRenderCost = false;
|
---|
21 |
|
---|
22 | while (!(getline(file, buf)).eof())
|
---|
23 | {
|
---|
24 | if (buf[0] == '#')
|
---|
25 | {
|
---|
26 | char entry[50];
|
---|
27 |
|
---|
28 | sscanf(buf.c_str(), "#%s", entry);
|
---|
29 |
|
---|
30 | if (strcmp(entry, "TotalRenderCost") == 0)
|
---|
31 | isRenderCost = true;
|
---|
32 | }
|
---|
33 | else if (isRenderCost)
|
---|
34 | {
|
---|
35 | float rc;
|
---|
36 | sscanf(buf.c_str(), "%f", &rc);
|
---|
37 |
|
---|
38 | renderCosts.push_back(rc);
|
---|
39 | isRenderCost = false;
|
---|
40 | }
|
---|
41 | }
|
---|
42 |
|
---|
43 | return true;
|
---|
44 | }
|
---|
45 |
|
---|
46 | int _tmain(int argc, _TCHAR* argv[])
|
---|
47 | {
|
---|
48 | vector<float> renderCosts1;
|
---|
49 | vector<float> renderCosts2;
|
---|
50 |
|
---|
51 | ifstream file1(argv[1]);
|
---|
52 | ifstream file2(argv[2]);
|
---|
53 |
|
---|
54 | ofstream statsOut(argv[3]);
|
---|
55 |
|
---|
56 | extractRenderCost(file1, renderCosts1);
|
---|
57 | extractRenderCost(file2, renderCosts2);
|
---|
58 |
|
---|
59 | //statsOut << "rc1 size: " << (int)renderCosts1.size() << " " << (int)renderCosts2.size() << endl << endl;
|
---|
60 | int n = min((int)renderCosts1.size(), (int)renderCosts2.size());
|
---|
61 |
|
---|
62 | if (argc > 4)
|
---|
63 | {
|
---|
64 | char *endptr = NULL;
|
---|
65 |
|
---|
66 | int limit = strtol(argv[4], &endptr, 10);
|
---|
67 |
|
---|
68 | n = min(n, limit);
|
---|
69 | }
|
---|
70 |
|
---|
71 | for (int i = 0; i < n; ++ i)
|
---|
72 | {
|
---|
73 | float costRatio = renderCosts2[i] != 0 ?
|
---|
74 | renderCosts1[i] / renderCosts2[i] : renderCosts1[i] / 0.0000001f;
|
---|
75 |
|
---|
76 | statsOut << "#ViewCells\n" << i + 1 << endl
|
---|
77 | << "#RenderCostRatio\n" << costRatio * 100.0f << endl;
|
---|
78 | }
|
---|
79 |
|
---|
80 | return 0;
|
---|
81 | }
|
---|
82 |
|
---|