-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #260 from stevehalliwell/soa
Merge soa into main: Add desugar based SOA
- Loading branch information
Showing
17 changed files
with
821 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
namespace ULox.Core.Bench | ||
{ | ||
public class ObjectVsSoa | ||
{ | ||
public const string ObjectBasedScript = @" | ||
class Foo | ||
{ | ||
var | ||
x = 0, | ||
y = 0, | ||
vx = 0, | ||
vy = 0, | ||
; | ||
} | ||
var foos = []; | ||
fun TickAllFoos(foos, dt) | ||
{ | ||
var count = foos.Count(); | ||
for(var i = 0; i < count; i +=1) | ||
{ | ||
var item = foos[i]; | ||
item.x = item.x + item.vx * dt; | ||
item.y = item.y + item.vy * dt; | ||
} | ||
} | ||
for(var i = 0; i < 1000; i+=1) | ||
{ | ||
foos.Add(Foo()); | ||
} | ||
for(var i = 0; i < 1000; i+=1) | ||
{ | ||
TickAllFoos(foos, 0.01); | ||
} | ||
"; | ||
|
||
|
||
public const string SoaBasedScript = @" | ||
class Foo | ||
{ | ||
var | ||
x = 0, | ||
y = 0, | ||
vx = 0, | ||
vy = 0, | ||
; | ||
} | ||
soa FooSet | ||
{ | ||
Foo | ||
} | ||
var foos = FooSet(); | ||
fun TickAllFoos(foos, dt) | ||
{ | ||
var count = foos.Count(); | ||
for(var i = 0; i < count; i +=1) | ||
{ | ||
foos.x[i] = foos.x[i] + foos.vx[i] * dt; | ||
foos.y[i] = foos.y[i] + foos.vy[i] * dt; | ||
} | ||
} | ||
for(var i = 0; i < 1000; i+=1) | ||
{ | ||
foos.Add(Foo()); | ||
} | ||
for(var i = 0; i < 1000; i+=1) | ||
{ | ||
TickAllFoos(foos, 0.01); | ||
} | ||
"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.