Generating Diffie-Hellman parameters efficiently
The standard solution is to generate $g$ and $p$ once during application development, then hardcode $g$ and $p$ in your code.  There are standard choices for $p$ and $g$, e.g., documented by NIST in their FIPS series.  I suggest using one of those.  There is no need to re-generate $g$ or $p$ each time.  You can use the same $g$ and $p$ for everyone.  See also Is it safer to generate your own Diffie-Hellman primes or to use those defined in RFC 3526? for more details in this vein.

And make sure you use larger parameters.  For security, I recommend that the prime $p$ should be at least 2048 bits long, and $g$ should generate a subgroup of size at least $2^{128}$ (or generate the whole group).

ECDHE will provide even better performance than Diffie-Hellman, but you can try the above first.  Hardcoding the parameters should already make a huge difference.