Arduino Ignition timing interceptor

Hello Forum.

I want to advance the ignition timing in a linear or close to linear fashion on my pit bike to increase performance.

My thought is that you could intercept the signal from the pickup on the flywheel that goes to the CDI box with a microcontroller. The point is to calculate the RPM of the engine and alter the signal to the cdi box so that it reaches the cdi box before the actual signal is given by the pickup.

The way i was going at this was, I would have the microcontroller count how long it takes between two signals from the pickup. Then i would make an array that has a given ignition time (Maybe a percentage of the milliseconds it takes for any given revolution?) to use for every RPM.

The program needs to keep track of the RPM by counting every pickup signal and calculating the RPM, and in between the signals, it needs to also fire the spark by enabling an output to the CDI's Input. The ignition output should be enabled according to the values given by the array, in the form of some milliseconds after the last pickup signal was recieved.

It seems to me that you have to make the microcontroller keep track of 2 different things at the same time, i find it hard to grasp which tools i should use to accomplish that.

Replies will be appreciated!