You can try that sketch. It will work only if both current and voltage waveforms are “well-behaved”, so that they are very close to pure sinusoids.
[Edit]
Having looked a little more closely at that sketch, but not having actually tested it, it would seem that it needs to take its inputs from some analogue processing that “squares off” the input waveforms. And even then, it would be susceptible to any distortion that moves the zero crossings.
Without that, I suspect it will also be sensitive to the amplitude of the signals.
[/Edit]
I’m told that this: Emontx3-continuous - New continuous monitoring firmware
does things differently to emonLib, so you could also try that. I have not yet managed to find time to look at it, so I can’t make any comment about it.