, C. :
Class methods: Time to complete: 0.00415796
Single instance: Time to complete: 0.00437099
Using Singleton: Time to complete: 0.071667
Using Global: Time to complete: 0.00534797
Using C function: Time to complete: 0.00302202
, , , ; .
To return to the original question, you should use the class method, since your methods are not dependent on any state (properties) that the instance may have. Performance is wise, this can only help because using the actual instance means you need to somehow distribute and access that instance, which adds overhead (again, all this is insignificant).
Using the C function will be imperceptibly faster, but you cannot subclass and override this C function as if you were using a class method.
source
share