Skip to content

Commit b4ec3a5

Browse files
committed
Scratch vs Stack benchmarking for COLL_PPTE
1 parent 7e042ed commit b4ec3a5

File tree

1 file changed

+75
-4
lines changed

1 file changed

+75
-4
lines changed

rewrite/src/profiler/benchmark.h

Lines changed: 75 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11

2-
void RunTest_RW_COLL_ProjectPointToEdge()
2+
// PPTE = ProjectPointToEdge
3+
// RW = Rewrite
4+
// ND = Naughty Dog (original)
5+
// STACK = $sp memory
6+
// SCRATCH = scratchpad
7+
8+
void RunTest_RW_COLL_PPTE_STACK()
39
{
410
// Sample input from no$psx
511
// $a0: 1f800154 - 0, 0, 0
@@ -18,7 +24,7 @@ void RunTest_RW_COLL_ProjectPointToEdge()
1824
}
1925
}
2026

21-
void RunTest_ND_COLL_ProjectPointToEdge()
27+
void RunTest_ND_COLL_PPTE_STACK()
2228
{
2329
// Sample input from no$psx
2430
// $a0: 1f800154 - 0, 0, 0
@@ -40,9 +46,74 @@ void RunTest_ND_COLL_ProjectPointToEdge()
4046
}
4147
}
4248

49+
void RunTest_RW_COLL_PPTE_SCRATCH()
50+
{
51+
SVec3* out = (SVec3*)0x1f800154;
52+
SVec3* v1 = (SVec3*)0x1f800270; //{0x0, 0x32A, 0xEDE4};
53+
SVec3* v2 = (SVec3*)0x1f800220; //{0xFD00, 0x2EC, 0xEA58};
54+
SVec3* point = (SVec3*)0x1f800164; //{0xFD6F, 0x2F5, 0xEDCE};
55+
56+
out->v[0] = 0;
57+
out->v[1] = 0;
58+
out->v[2] = 0;
59+
60+
v1->v[0] = 0x0;
61+
v1->v[1] = 0x32A;
62+
v1->v[2] = 0xEDE4;
63+
64+
v2->v[0] = 0xFD00;
65+
v2->v[1] = 0x2EC;
66+
v2->v[2] = 0xEA58;
67+
68+
point->v[0] = 0xFD6F;
69+
point->v[1] = 0x2F5;
70+
point->v[2] = 0xEDCE;
71+
72+
// million
73+
for(int i = 0; i < 1000000; i++)
74+
{
75+
COLL_ProjectPointToEdge(out, v1, v2, point);
76+
}
77+
}
78+
79+
void RunTest_ND_COLL_PPTE_SCRATCH()
80+
{
81+
SVec3* out = (SVec3*)0x1f800154;
82+
SVec3* v1 = (SVec3*)0x1f800270; //{0x0, 0x32A, 0xEDE4};
83+
SVec3* v2 = (SVec3*)0x1f800220; //{0xFD00, 0x2EC, 0xEA58};
84+
SVec3* point = (SVec3*)0x1f800164; //{0xFD6F, 0x2F5, 0xEDCE};
85+
86+
out->v[0] = 0;
87+
out->v[1] = 0;
88+
out->v[2] = 0;
89+
90+
v1->v[0] = 0x0;
91+
v1->v[1] = 0x32A;
92+
v1->v[2] = 0xEDE4;
93+
94+
v2->v[0] = 0xFD00;
95+
v2->v[1] = 0x2EC;
96+
v2->v[2] = 0xEA58;
97+
98+
point->v[0] = 0xFD6F;
99+
point->v[1] = 0x2F5;
100+
point->v[2] = 0xEDCE;
101+
102+
// Revert the Hook from OG -> DECOMP
103+
PatchFunction_Beg((u32*)(&ND_COLL_ProjectPointToEdge));
104+
105+
// million
106+
for(int i = 0; i < 1000000; i++)
107+
{
108+
ND_COLL_ProjectPointToEdge(out, v1, v2, point);
109+
}
110+
}
111+
43112
// Always run RW (rewrite) before OG (original)
44113
struct BenchTest tests[] =
45114
{
46-
ADDTEST(RunTest_RW_COLL_ProjectPointToEdge),
47-
ADDTEST(RunTest_ND_COLL_ProjectPointToEdge)
115+
ADDTEST(RunTest_RW_COLL_PPTE_STACK),
116+
ADDTEST(RunTest_ND_COLL_PPTE_STACK),
117+
ADDTEST(RunTest_RW_COLL_PPTE_SCRATCH),
118+
ADDTEST(RunTest_ND_COLL_PPTE_SCRATCH),
48119
};

0 commit comments

Comments
 (0)