Showing posts with label objic. Show all posts
Showing posts with label objic. Show all posts

Benchmarking


I just did some benchmarks on objic (objects in the cloud) my final year dissertation. The result was not very pleasing, it doesn't seam to scale too well. It becomes quite clear that the more loop iterations there are the longer it will take. Not even linear execution like python, looks more like exponential. I will have to investigate why this is but I think it might be the garbage collection algorithm. This was just a for loop done 10, 100, 1000 and 10000 times.

FFS more work

Using eval to use a string as comparison

I am just writing a little compiler and interpreter and I have a method to check if 2 values are equal, not equal greater and so on. My code looked something like this

if typeOfCompare == "==":
return firstVal == secondVal

elif typeOfCompare == "!=":
return firstVal != secondVal

elif typeOfCompare == "<=":
return firstVal <= secondVal

....
But this was quite inflexible and I didn't like all the returns. As the type of the comparison was already checked by the parser I came up with a simpler method
return eval(str(firstVal) + typeOfCompare  + str(secondVal))
This might be a performance hit and not as clear but its easier to code and more extensible. You got to love python enabling something like this using a string as comparison operator.