What's the best way drive multiple LEDs simultaneously?

Hi, I'm new to arduino. I currently have a mega 2560 and about 40 LEDs. I want to drive them one by one and also some (or all) selected LEDs at the same time. From the reference, it seems that I can use port manipulation (DDRX, PORTX). However since all the pins are spread out to multiple ports, will there be a lot delay between pins located in different ports?

Not so that you would notice. 16 MHz is pretty darn fast!

You can use the normal digitalWrite on all the pins and you will still not see any delay.

Just beware of the total current limit of the mega. I believe it's 200ma, which would be 5ma per LED to prevent damage.

I believe it’s 200ma,

Bit of a grey area this. The data sheet says power & ground is limited to 200mA per pin. But the Mega chip has 4 pins so that might make it 800mA. But others disagree.