-
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.
- Loading branch information
Showing
10 changed files
with
122 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "lib/benchmark"] | ||
path = lib/benchmark | ||
url = https://github.com/google/benchmark.git |
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
Empty file.
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,26 @@ | ||
#include <benchmark/benchmark.h> | ||
#include "../src/Structs/Vector2.h" | ||
#include "../src/Structs/Vector3.h" | ||
|
||
// Example benchmark for Vector2 | ||
static void BM_Vector2_Addition(benchmark::State& state) { | ||
Vector2 a(1.0f, 2.0f); | ||
Vector2 b(3.0f, 4.0f); | ||
for (auto _ : state) { | ||
benchmark::DoNotOptimize(a + b); | ||
} | ||
} | ||
BENCHMARK(BM_Vector2_Addition); | ||
|
||
// Example benchmark for Vector3 | ||
static void BM_Vector3_Addition(benchmark::State& state) { | ||
Vector3 a(1.0f, 2.0f, 3.0f); | ||
Vector3 b(4.0f, 5.0f, 6.0f); | ||
for (auto _ : state) { | ||
benchmark::DoNotOptimize(a + b); | ||
} | ||
} | ||
BENCHMARK(BM_Vector3_Addition); | ||
|
||
// Main function to run benchmarks | ||
BENCHMARK_MAIN(); |
File renamed without changes.
File renamed without changes.
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,36 @@ | ||
#ifndef VECTOR2_H | ||
#define VECTOR2_H | ||
|
||
#include <cmath> | ||
|
||
struct Vector2 { | ||
float x, y; | ||
|
||
Vector2(float x = 0, float y = 0); // Constructor | ||
|
||
// Magnitude of the vector | ||
float magnitude() const; | ||
|
||
// Normalized vector | ||
Vector2 normalized() const; | ||
|
||
// Dot product | ||
float dot(const Vector2& other) const; | ||
|
||
// Addition | ||
Vector2 operator+(const Vector2& other) const; | ||
|
||
// Subtraction | ||
Vector2 operator-(const Vector2& other) const; | ||
|
||
// Multiplication by scalar | ||
Vector2 operator*(float scalar) const; | ||
|
||
// Division by scalar | ||
Vector2 operator/(float scalar) const; | ||
|
||
// Equality check | ||
bool operator==(const Vector2& other) const; | ||
}; | ||
|
||
#endif // VECTOR2_H |
File renamed without changes.
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,42 @@ | ||
#ifndef VECTOR3_H | ||
#define VECTOR3_H | ||
|
||
#include <cmath> | ||
|
||
struct Vector3 { | ||
float x, y, z; | ||
|
||
Vector3(float x = 0, float y = 0, float z = 0); // Constructor | ||
|
||
// Magnitude of the vector | ||
float magnitude() const; | ||
|
||
// Normalized vector | ||
Vector3 normalized() const; | ||
|
||
// Dot product | ||
float dot(const Vector3& other) const; | ||
|
||
// Cross product | ||
Vector3 cross(const Vector3& other) const; | ||
|
||
// Addition | ||
Vector3 operator+(const Vector3& other) const; | ||
|
||
// Subtraction | ||
Vector3 operator-(const Vector3& other) const; | ||
|
||
// Multiplication by scalar | ||
Vector3 operator*(float scalar) const; | ||
|
||
// Division by scalar | ||
Vector3 operator/(float scalar) const; | ||
|
||
// Equality check | ||
bool operator==(const Vector3& other) const; | ||
|
||
// Inequality check | ||
bool operator!=(const Vector3& other) const; | ||
}; | ||
|
||
#endif // VECTOR3_H |