Skip to content

Commit

Permalink
sampler
Browse files Browse the repository at this point in the history
  • Loading branch information
notgiven688 committed Dec 18, 2024
1 parent b3705a6 commit 7b55afc
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/JitterDemo/Playground.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using Jitter2;
using Jitter2.Collision;
using Jitter2.Collision.Shapes;
Expand Down Expand Up @@ -106,6 +107,9 @@ public override void Load()
ResetScene();

VerticalSync = false;

SwitchDemo(2);
multiThread = true;
}

public RigidBodyShape? FloorShape => floorShape;
Expand All @@ -130,7 +134,12 @@ public void ShootPrimitive()
public override void Draw()
{
// if (Keyboard.KeyPressBegin(Keyboard.Key.P))
var swn = Stopwatch.StartNew();
world.Step(1.0f / 100.0f, multiThread);
swn.Stop();

System.IO.File.AppendAllText("stats.dat",
$"{swn.Elapsed.TotalMilliseconds}\n");

UpdateDisplayText();
LayoutGui();
Expand Down
31 changes: 31 additions & 0 deletions src/JitterDemo/plot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import matplotlib.pyplot as plt

# Load the data from the files
with open("stats.dat", "r") as f1:
y1 = [float(line.strip()) for line in f1 if line.strip()]

with open("stats.main.dat", "r") as f2:
y2 = [float(line.strip()) for line in f2 if line.strip()]

#with open("stats.dat", "r") as f2:
# y3 = [float(line.strip()) for line in f2 if line.strip()]

# Create x-values (row numbers)
x1 = range(len(y1))
x2 = range(len(y2))
#x3 = range(len(y3))

# Plot the data
plt.figure(figsize=(8, 6))
plt.plot(x1, y1, marker="o", linestyle="-", color="b", label="stats.dat")
plt.plot(x2, y2, marker="x", linestyle="--", color="r", label="stats.main.dat")
#plt.plot(x3, y3, marker=".", linestyle="-", color="g", label="stats.main.dat")

# Customize the plot
plt.xlabel("Row Index")
plt.ylabel("Values")
plt.title("Values from stats.dat and stats.main.dat")
plt.legend()
plt.grid()
plt.show()

0 comments on commit 7b55afc

Please sign in to comment.