Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
data locality - slow example
//https://www.youtube.com/watch?v=TJHgp1ugKGM //g++ 5.4.0 #include <iostream> #include <vector> class AIComponent { public: void update() { /* Work with and modify state... */ } private: // Goals, mood, etc. ... }; class PhysicsComponent { public: void update() { /* Work with and modify state... */ } private: // Rigid body, velocity, mass, etc. ... }; class RenderComponent { public: void render() { /* Work with and modify state... */ } private: // Mesh, textures, shaders, etc. ... }; class GameEntity { public: GameEntity(AIComponent* ai, PhysicsComponent* physics, RenderComponent* render) : ai_(ai), physics_(physics), render_(render) {} AIComponent* ai() { return ai_; } PhysicsComponent* physics() { return physics_; } RenderComponent* render() { return render_; } private: AIComponent* ai_; PhysicsComponent* physics_; RenderComponent* render_; }; int main() { std::vector<GameEntity> entities; int total = 10000000; for(int i=0; i<total; i++) { auto ge = GameEntity(new AIComponent(), new PhysicsComponent(), new RenderComponent()); entities.push_back(ge); } for(auto& e: entities) { e.ai()->update(); } for(auto& e: entities) { e.physics()->update(); } for(auto& e: entities) { e.render()->render(); } }
run
|
edit
|
history
|
help
0
sdfsdf
CODE K
Continuous Sub Set with given sum
Pruebas estocasticos
on_off
Longest Palindrom in String
Two-phase sample with GCC
ThreadPool
gal
Projekt misker