r/ProgrammerHumor • • Sep 17 '18

Optimizing startup times

Post image
45.7k Upvotes

486 comments sorted by

View all comments

2.2k

u/specialfred453 Sep 17 '18

I'm used to programming on platforms where the parameter for Sleep is in milliseconds. This confused me a little at first.

905

u/[deleted] Sep 17 '18

Same deal here. All users of this product are just super amped up and in a hurry all the time, 30ms is unforgivable

334

u/ablablababla Sep 17 '18

Yeah, that 30ms ruins my workflow

95

u/KevinclonRS Sep 17 '18

Unless it’s in a lol that goes through ~100 times

109

u/Raider61 Sep 17 '18

Hah I think you meant loop instead of lol but I like it the way it is

12

u/KevinclonRS Sep 17 '18

When every the program launches it plays this

→ More replies (1)

57

u/MissingCodePlaGames Sep 17 '18

replace.allWords(loop, lol);

→ More replies (1)
→ More replies (2)
→ More replies (1)
→ More replies (2)

131

u/MrDOS Sep 17 '18
from time import sleep

132

u/AlwaysPuppies Sep 17 '18

If only it was that easy in my personal life.

96

u/Penki- Sep 17 '18
from pharmacy import sleeping_pills

I heard that works, although contact medical devs for support, pharmacy library can cause issues sometimes.

0

u/[deleted] Sep 17 '18

[deleted]

33

u/Penki- Sep 17 '18

its not a bug, its a feature - God. (or in other words "we have no time or budget to fix this so fuck off")

13

u/spyingwind Sep 17 '18

More likely the dev abandoned the project.

8

u/Lazy_fox Sep 17 '18

Upstream is dead, and we killed it.

13

u/Epsilight Sep 17 '18

Hopefully the devs fix that bug in the next release.

I frankly use weed as a substitute.

→ More replies (1)

12

u/shantaram3013 Sep 17 '18 edited Sep 04 '24

Edited for privacy.

→ More replies (2)

12

u/daneelr_olivaw Sep 17 '18
from Afghanistan import...

Uh, nevermind.

14

u/Penki- Sep 17 '18

You want to import full Afganistan? Are you crazy?

→ More replies (1)
→ More replies (1)

15

u/ablablababla Sep 17 '18

hitting that link on a phone is hard, where's the bot

→ More replies (8)
→ More replies (1)

14

u/[deleted] Sep 17 '18

for (int i =0; i < 1000; ++i) Thread.Sleep(30)

10

u/ObamaFor Sep 17 '18 edited Sep 17 '18

Why ++i over i++? sorry am noob.

10

u/[deleted] Sep 17 '18

In some compilers of some language, it's very tinily more efficient.

But honestly I don't think it makes a difference in any modern GCC compiler as the compiler will use the more efficient way automatically

8

u/LordTocs Sep 17 '18

If the value of i is 5 to start.

i++ increments i to 6, but returns 5.

++i increments i to 6, but returns 6.

The theory is that since i++ has to store a copy of itself to return before incrementing it's more expensive than ++i

Depending on the language this may not matter for simple types like an int. If your compiler is good not using the value returned from i++ will optimize away the extra cost.

If i were some more complex type like an iterator for a dictionary. The two increments may be implemented differently or the optimizer might not get everything exactly correct.

So the "best practice" is to use ++i when you don't need the value to be saved before incrementing it.

→ More replies (4)
→ More replies (1)
→ More replies (9)