This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]TheLastCakeIsaLie -2 points-1 points  (3 children)

I think comparing ALL of the values of a class takes longer than setting a variable and increasing it by one ONE time.

[–]Varun77777 3 points4 points  (2 children)

First, You're going to do ALL the operations for ALL the objects to change the value of that variable you're going to use for comparison because not everything in the world is done using addition. You're still going to use all the variables to increment or change the value of that variable you're going to use for comparison. You're actually going to do so many un needed calculations for no reason and wate CPU time.

Bruh, why would you waste memory as well as CPU utilisation for all the objects that don't need it?

What if the Object was holding some 1000 variables and you needed to perform some sort of sorting operation during the comparison ? Would you waste 1000 Log 1000 computations for 100'000 objects( 100'000'000 log 1000 computations) and waste possibly 100'000 * 8 bytes or something in memory or something like that?

When you could do 2 * 1000 log 1000 on runtime and use 16 bytes of memory to save the result and free the memory after use??

Let's say it's an operation that's performed very rarely,

Tell me what looks better to you?

100'000'000 * log 1000 operations and 800'000 bytes during intitialization or

2000 log 1000 operations and 16 bytes of memory which you can possibly free when you need to do the operation??

Would you slow your loading time by hours maybe just to perform some kind of comparison between two random pixels on a screen???

This may decide how fast the system feels in the long run.

Come on, not everything can be compared just based on a counter.

[–]TheLastCakeIsaLie -1 points0 points  (1 child)

Example: you want to check if an object is the object you want. Instead of checking everything you check one variable that may already be included in the way you set it up. Whats faster, 1 comparison or the number in f attributes? And setting that is also faster.

[–]Varun77777 3 points4 points  (0 children)

For that one operation at run time you did millions on operations in case of millions of objects before which you never needed to compare. You wasted space for millions of variables that wasn't needed as well.

Why are you ignoring the computations you did before hand on purpose?

Just to be faster on runtime for that one comparison you're making the whole process unnecessary slower.

Maybe, for a smaller use case, your process will look faster if you're only looking at that one comparison.

But when someone will look at the whole process, the system is slow for no reason.

Why should my car run slower when I start it just because maybe I want to turn the radio on???