I want to test a proxy [gateway] service. What would be the simplest script to check the proxy’s IP speed and  performance? See the following script.

Run this script within a loop, iterating over url(s) or rotating proxy value if needed. The script accumulates total url visits (total_visits) and also tallies the various exceptions (Timeout, TooManyRedirects and Request exceptions) into corresponding variables.

Note: only Request exceptions are caused by a proxy server. The other kinds of exceptions are website (resource) specific: Timeout and TooManyRedirects exceptions.
For calculating the performance of a proxy server, I do the following:

Thus I get a proxy server performance value (in most cases close to 100%).