Skip to content

Instantly share code, notes, and snippets.

View SanderMertens's full-sized avatar
🐥
Feeding flecs

Sander Mertens SanderMertens

🐥
Feeding flecs
View GitHub Profile
#include <prefab_storage_tests.h>
#include <stdio.h>
ECS_COMPONENT_DECLARE(Position);
ECS_COMPONENT_DECLARE(Rotation);
ECS_COMPONENT_DECLARE(Velocity);
ECS_COMPONENT_DECLARE(Transform);
ECS_COMPONENT_DECLARE(TransformRef);
ECS_COMPONENT_DECLARE(Parent);
ECS_COMPONENT_DECLARE(Children);
using flecs.script.*
using flecs.components.*
using flecs.game
const Stone = Rgb: {0.4, 0.3, 0.3}
const SideWalk = Rgb: {0.4, 0.4, 0.4}
const Concrete = Rgb: {0.3, 0.3, 0.3}
const Door = Rgb: {0.1, 0.07, 0.04}
const Frame = Rgb: {0.7, 0.7, 0.7}
const Awning = Rgb: {0.06, 0.08, 0.05}
@SanderMertens
SanderMertens / bevy_bench.rs
Last active June 6, 2025 00:06
Bevy benchmark
// Code uses a custom benchmarking solution (vs. criterion) so that the numbers
// are comparable to the Flecs benchmarks in this repository:
// https://github.com/SanderMertens/ecs_benchmark
use bevy_ecs::prelude::*;
// use bevy_hierarchy::*;
use bevy_ecs::world::CommandQueue;
use std::hint::black_box;
use rand;
// Test for importing script from URL
using flecs.components.*
using flecs.game
using assemblies
town :- Town{}
#include <c_app.h>
#include "flecs.h"
#include <stdio.h>
#include <stdlib.h>
#define STARS (1000)
#define PLANETS_MAX (10)
#define P_PLANET_WATER (0.1)
#define P_PLANET_OIL (0.005)
#define P_PLANET_COPPER (0.05)

Clang

8

size_t pretty_type() [T = Position]
size_t pretty_enum() [E = Color, C = Red]
size_t pretty_enum() [E = Color, C = 3]
#include <bench_path.h>
#include <stdio.h>
#include <stdlib.h>
#include "entt.hpp"
#define MILLION (1000 * 1000)
#define BILLION (1000 * MILLION)
#define ENTITY_COUNT (255)
#define COMPONENT_COUNT (10)
entity.add<MeleeUnit>();
// Utility for adding features (mixins) to a class without modifying its
// definition.
// -- Mixin code
// Create macro for mixin template type so we don't go cross-eyed
#define MIXIN template<typename Self> typename
// Template that can store a list of mixin templates
// Summary of Flecs data structures
// This is a non-exhaustive overview of flecs datastructures. Things have been ommitted/have different names for clarity.
// --- DATASTRUCTURES
// A sparse set is a map-like structure that guarantees O(1) lookup times (as opposed to O(1) on average for maps) at the cost of
// requiring more RAM (more info on the general idea of sparse sets: https://www.geeksforgeeks.org/sparse-set/)
struct ecs_sparse_t { };