I have recently been implementing an Entity-component system for my game engine. Every entity keeps a map of components like that :

Component.h

```
enum COMPONENT_INFO {
    COMPONENT_POSITION = 0, 
    COMPONENT_PHYSICS,
    COMPONENT_RENDERABLE
 };

```

Entity.h

```
class Entity {
public:
    std::bitset<NUM_COMPONENTS> componentBits;
    std::map<COMPONENT_INFO, Component*> components;
    ..
    ..

    Component *getComponent(COMPONENT_INFO inf) {
        return components[inf];
    }
 };

```

And my System class updates every entity per frame like that :

```
void update(Entity *e, float delta) { 
        PositionComponent *cmp=(PositionComponent*)e->getComponent(COMPONENT_INFO::COMPONENT_PHYSICS);
        //x += 1.0f;
        cmp->x += 1.0f;
    }

```

Everything works as intended, but I have a huge performance problem in accessing the map. When I create 10000 entities and iterate through them (the system iterates through actually), I get 80 FPS with a blue blank system(no visual effects, just plain screen). But when I comment out the access parts and only use `x += 1.0f;`, FPS increadibly increases to 1000. Like that :

```
void update(Entity *e, float delta) { 
        x += 1.0f; //btw the system has a local x value.
    }

```

So the problem is simply at accessing the components through the map. What else can I use on a system like that ? Or maybe I am doing something wrong in accessing the map ? 

Important Edit : This is just a test drive, I mean there might be lots of components per entity, not just 3. I wrote these for just testing purposes.