Esempio n. 1
0
 def get_mem_usage(self):
     import simpleecs
     import simpleecs.components
     return (
         sys.getsizeof(simpleecs.World().create_entity()),
         sys.getsizeof(simpleecs.components.NullComponent())
     )
Esempio n. 2
0
def benchmark(num_entities=1, num_components=1):
    print('Entities: {}, Components: {}'.format(num_entities, num_components))
    start = time.perf_counter_ns()
    world = simpleecs.World()
    system = NullSystem()
    world.add_system(system)
    for _ in range(num_entities):
        entity = world.create_entity()
        for j in range(num_components):
            comp = globals()['NullComponent{}'.format(j)]()
            entity.add_component(comp)
    setup_end = time.perf_counter_ns()
    world.update(0)
    update_end = time.perf_counter_ns()
    world.update(0)
    warm_update_end = time.perf_counter_ns()

    setup_time = (setup_end - start) / 100_000
    update_time = (update_end - setup_end) / 100_000
    warm_update_time = (warm_update_end - update_end) / 100_000
    total_time = setup_time + update_time
    print(
        '\t{:0.2f}ms (setup: {:0.2f}ms, update: {:0.2f}ms, warm update: {:0.2f}ms)'
        .format(
            total_time,
            setup_time,
            update_time,
            warm_update_time,
        ))

    return total_time, setup_time, update_time
Esempio n. 3
0
    def setup(self, num_entities, num_components):
        import simpleecs
        import simpleecs.systems

        self.world = simpleecs.World()
        self.world.add_system(
            simpleecs.systems.NullSystem(),
        )

        for _ in range(num_entities):
            self.world.create_entity([
                self.component_classes[compnum]
                for compnum in range(num_components)
            ])
Esempio n. 4
0
def world():
    return simpleecs.World()
Esempio n. 5
0
    warm_update_end = time.perf_counter_ns()

    setup_time = (setup_end - start) / 100_000
    update_time = (update_end - setup_end) / 100_000
    warm_update_time = (warm_update_end - update_end) / 100_000
    total_time = setup_time + update_time
    print(
        '\t{:0.2f}ms (setup: {:0.2f}ms, update: {:0.2f}ms, warm update: {:0.2f}ms)'
        .format(
            total_time,
            setup_time,
            update_time,
            warm_update_time,
        ))

    return total_time, setup_time, update_time


if __name__ == '__main__':
    print('=Memory=')
    print('Entity: {}, NullComponent: {}'.format(
        sys.getsizeof(simpleecs.World().create_entity()),
        sys.getsizeof(globals()['NullComponent0']())))
    print()

    print('=Time=')
    INCS = [1, 100, 1000]
    for num_ent in INCS:
        for num_comp in INCS:
            benchmark(num_entities=num_ent, num_components=num_comp)