For esp, I had to make a couple of changes to the sketch. I knew I would need to use 32 bit rather than 8, but upon compiling, I realised I also had to use pointers.
#define PIN D2
volatile uint32_t *myPort;
uint32_t myPinBit;
...
*myPort |= myPinBit;
*myPort &= ~myPinBit;
Wemos Mini (esp8266 @80MHz):
digitalWrite() 0.46us, Port Manipulation 0.28us which is 1.62 times faster
Wemos Mini (esp8266 @160MHz):
digitalWrite() 0.23us, Port Manipulation 0.21us which is 1.11 times faster
Strangely, at 160MHz, the port manipulation time did not halve as I expected. I increased the loops to 1,000,000, but got the same result.