r/shittyprogramming • • Dec 10 '14

This Google new code that makes Google search 100-150 milliseconds faster. Notice that the function ends in line 1.

Post image
221 Upvotes

30 comments sorted by

7

u/[deleted] Dec 10 '14

31

u/zim2411 Dec 10 '14

to be exact, 100-150 milliseconds faster

To be exact, here's an estimate!

35

u/[deleted] Dec 10 '14

If it falls within those limits exactly, it's exact.

-3

u/[deleted] Dec 10 '14 edited Dec 10 '14

Then 0-9999999 milliseconds faster would also be exact. They could give us an average instead.

Edit: average is not a good idea, so as I was told.

16

u/PumpkinSeed Dec 10 '14

My guess would be the range is representative of the standard deviation.

4

u/[deleted] Dec 10 '14

Well, haven't thought about that, but yeah. It could be.

7

u/Tonnac Dec 10 '14

An average is even less exact than a hard limited range.

2

u/[deleted] Dec 10 '14

Well pointed.

0

u/[deleted] Dec 10 '14

[deleted]

3

u/Tonnac Dec 10 '14

I disagree. An average without a sigma means literally nothing. An average of 0.5 could have a 3 sigma range of [0.4-0.6] or one of [0-5] since it's not even sure to be standard deviation. A limited range at least tells you what the most extreme values you can expect are.

4

u/cooper12 Dec 10 '14 edited Dec 10 '14

Real life doesn't work in exact figures when doing tests. The reason is that you won't always get the same result each time, especially since the results in this case depend on the resources of the target websites. They could've said 125 ms, but that would be inaccurate since a user might get up to or past 25 ms faster or slower results.

The best way to envision it is that certain types of samples conform to a bell curve distribution. In this curve, 125 would lie at the center, and 99.7% (or 95% or 68% depending on how many standard deviations 25 is) of the curve would be in the range from 100-150. The best way to represent this is 125 ± 25, which is how they did it.

3

u/zim2411 Dec 10 '14

Right, I just find it funny he wrote "to be exact" -- no, that isn't exact at all. The results will depend far more on the user's connection than anything else. Are you on wifi tied to a connection with a 20 ms ping, or slow cell connection with 200 + ms?

2

u/cooper12 Dec 10 '14

Fair point. For all we know they just tested this on google fiber haha, but the way I thought of it was that they said "faster", so it's probably a comparison to the previous method on the same connection. It really depends on their sample.

2

u/ajs124 Dec 10 '14

slow cell connection with 200 + ms

you call 200 ms slow for a cell connection? I actually managed to get close to 60 s (as in seconds) with EDGE once, no idea how those packets even found back to me…

2

u/zim2411 Dec 10 '14

I scrolled back through my recent Speedtest logs and my worst within the past year and a half was 1.63 Mbps down, .03 Mbps up, 214 ms ping. My absolute worst ping on record is 483 ms in 2011, which would have been with my iPhone 4.

60 seconds is terrible, but I'm assuming/hoping that was a few years ago. I can't remember the last time I was on EDGE.

1

u/ajs124 Dec 11 '14

I don't know how long ago that was, but rural areas with a "3rd grade" carrier (e-plus, Germany) sometimes don't offer 3G. Or any data service , not even GPRS for that matter…

1

u/tangerinelion Dec 10 '14

Typically one quotes 1 sigma, so 125 ± 25 I would assume to mean the 68% CI.

There are other ways to define it, particularly if you have a lot of measurements and they don't fit a normal distribution very well. You could simply choose the range [a,b] that covers 68% of the measurements with the property that |b-a| is the minimum of |y-x| for all such ranges [x,y] that cover 68% of measurements. I say "simply" but the solutions tend to be rather brute force when you have no underlying distribution to exploit mathematically. Simple in the programming sense, but hey, that's an issue for the CPU to work out, not me.

1

u/cooper12 Dec 10 '14

Right, it's usually 1 S.D. The method you mention is very interesting. Much more advanced than the things I learned from my statistics course, where we usually assumed the distribution was normal if the sample size was > 30 or just dealt with tails-end distributions. Nice to know that computing power has helped to advance methods for non-normal distributions.

83

u/UnspeakableEvil Dec 10 '14

I frequently write code which makes things 100-150 milliseconds faster, I just neglect to tell people that's a mathematical statement rather than a range.

74

u/r0Lf Dec 10 '14

p.p.s. yes, I see there is an extra brace in the example; can't fix it now, and it's driving me nuts! And no, we're not throwing exceptions because of it on the search page :-)

Come on man, cut them some slack! It happens to everyone.

25

u/nakilon Dec 10 '14

Is it Obama's line?

6

u/Hamburgex Dec 10 '14

is this a meme now

58

u/Reelix Dec 10 '14

1.) Go to this site
2.) Browse around
3.) Notice there's no lag
4.) Look at Google, and laugh

2

u/[deleted] Dec 12 '14

I've just been getting into web dev and this is almost magical to me. I tried it on my site and it really does work well.

0

u/[deleted] Dec 10 '14

[deleted]

7

u/SDCorp Dec 11 '14

Didn't Google buy and/or make Angular??

0

u/[deleted] Dec 11 '14

[deleted]

3

u/SDCorp Dec 11 '14

Oh... HAHAHAHAHAHAHAHAHAHAHAQ

11

u/ahanix1989 Dec 10 '14

So it only works on Chrome for Android. They intentionally made the mobile version use more data?

0

u/[deleted] Dec 10 '14

[deleted]

5

u/ahanix1989 Dec 10 '14

Is it other resources on the same page? Have it preload ads, that shit always drags

4

u/beans-and-rice Dec 10 '14

Wouldn't a unit test have caught that?

4

u/tangerinelion Dec 10 '14

Wouldn't proper indentation have caught that? If it could be validated syntactically my guess is that closing } at the end is unmatched, or if not that one then the final one at the end of the file.

15

u/YRYGAV Dec 10 '14

The image was just an example a google engineer used in a blog post. It's not the actual production code.