Transcripción
Extracto de la transcripción automática del vídeo realizada por YouTube.
we're on Ron okay hello welcome hello hello hello I'm really glad I can be behind this podium here because I'm not wearing any pants no I'm not I'm wearing shorts anyway welcome I'm really honored to be here I'm happy to be the
first person to welcome you to the red dot Ruby caja I want to say thank you to everybody for coming thanks to the organizers think Thank You Winston thank you all of you please give yourselves a round of applause very happy to be here one interesting thing
about being the last speaker is that the only thing between you and the party isn't it so I was thinking that I would just do everything very slow as long as possible that's actually the longest transition keynote will do I was also thinking maybe
we would just stand around and watch animated gifts all day I like this one it's pretty funny he's standing there dancing yeah when is that party sorry my name is Aaron Patterson I've come to you from the United States to bring freedom whether
you like it or not do we have any Germans here tonight anyone from Germany yeah I heard we won freedom yeah I couldn't figure out how to make me like jets fly across Saturday anyway I'm on the I'm on the Ruby core team I'm also on the rails
core team um and this is my first time to give a talk I'm just kidding so you can find me on twitter as tenderlove I'm also on github as tenderlove Instagram is tender love and also ano is tender love so you can yo me there I think about weird stuff
all the time for some reason I don't I really don't know why I just like just weird stuff always comes to my mind like for example people always say like separation of concerns like I heard that a lot at this conference I hear it a lot all the time
as a programmer and the only thing that I can think of is basically this just that's all I can think I can't take it seriously okay anyway I recently became the number one committer on rails I'm the top I on the top ton of internet points so many
internet points I think this is out of date I think I actually have more commits than that now but let me tell you I'm gonna give you all the secret to getting internet points I'm gonna give you this is the secret this is my secret I'm giving it
away here is that revert commits count too so more mistakes equals more so don't be afraid to make mistakes you can't I'm a short stack engineer I think that's actually a full sack but I don't know I'm a short stack engineer I enjoy
I enjoy pair programming that's neat pair programming the interface is a little sticky on that getting the tty to work was difficult i I guess I'm also a dad joke programmer it's who I was tell a lot of bad dad jokes anyway I have a cat this is
my cat his name is Gorbachev puff puff thunderhorse actually I have two cats this is my other cat her name is SeaTac Airport YouTube Facebook - is her name also that's that's her actually my wife told me the reason we got the other cat was so that
or was the reason we got two cats is so that I would stop looking at pictures of cats online like that's that's not how this works you see now we have two cats and I look at cat pictures anyway I'm also a very shy person I you might you might think
area and how are you getting up in front of all these people and talking to them if you're very shy well it's actually because I'm really excited about my work I love my job and I also love like I want people to know what I do so I use that to
like give myself the courage to be up here but also like I brought so I brought a whole bunch of stickers of my cat and I like I am really terrible at starting conversations I'm very shy and awkward so if you want to come talk to me come up and say hey
Erin I would like a sticker and then I'll say here's a sticker of my cat and then we can talk about cats or programming or whatever so it's like a little icebreaker there anyway so I was thinking about this thinking about this conference and I
looked at like so last year I thought about the stuff that I did here and red-dot rubyconf last year last year I went to I went to Hawker centers and there's amazing food I ate some really really awesome food this is one of the things I hate I also thought
about like so last year I thought about this is so this is a map of the world I came from here that's I'm from Seattle in the United States there and we're down here in Singapore and the problem is that like I love food a lot I love food a lot
I eat all the time and it's very very bad for my weight but I was thinking that well so I am very far north typically right and we are now pretty far south and if we take a look at the earth from the top like there on the right that's where I am in
Seattle and down there on the on the bottom right that's in that's us in Singapore and actually the earth is you know the earth has the same we're rotating faster down here than we are up in Seattle so I should be being flung away from the earth
faster like if we move that up there right so that means that down here in Singapore I weigh less because I'm being pushed away from the earth all right so I was trying to calculate this I was trying to figure this out and I thought okay there's here's
all that and I'm like okay let's plug in some numbers here and I plug in these numbers and I'm plugging them in and trying to figure it out and then I'm like I have no idea what I'm doing I couldn't figure this out but hey like this
is all I was trying to figure this out last year - I I couldn't figure it out last year and actually like one of my fond memories of this conference from last year was talking to Jim Wyrick about this and he actually calculated all this for me and presented
it in his flies and told me exactly how much weight I lost and I was down here I was digging through digging through old photos that I took from last year and I found this one where he was comparing himself to my cat so anyway I just like I wanted to have
a slide in here that just said we missed you Jim he is so he was a huge huge inspiration to me and like one of the reasons I try to do my best presenting is because I know that he enjoyed watching me speak so I'm doing my best all the time now to try and
remember him the other thing another thing that I did last year is I ate durian fruit for the first time and this is this is picture the durian fruit that I ate and I actually really liked it I enjoyed it at first I thought it smelled incredibly bad and then
I tried it and I got it and I thought it was great it was great that's me the first time I had it and my wife came with me too and she tried it as well and so I was like taking some reaction shot photos so I've got like this is her before before eating
durian fruit and then asked so she didn't really enjoy it as much as I did but I really liked it anyway I've also been I've been studying nodejs a lot lately yeah and the reason I'm doing it the reason I'm studying note is so that I can
get a lot closer to the metal and I think that I've accomplished that like pretty close pretty close to the metal now anyway so I'm gonna top my talk is called speed-up rail speed up your code but I guess really it should be called rails on specs or
maybe this is not magenta something so I'm gonna talk a lot about I'm going to talk a lot about performance and rails and performance in your own code like basically benchmarking stuff how to benchmark stuff how to measure performance of your applications
and I have an ulterior motive for teaching you how to measure measurement performance of your applications and I will talk about that at the very very end of this talk but basically we're gonna look at how to imagine performance of code and then how I
measure performance of rails and how we've increased improved performance of rails and hopefully we can take that you'll be able to take these tools that I show you home and apply them to your code at home be it rails or not so the first thing I want
to talk about is performance trade-offs and typically when we're talking about performance we have to make trade-offs we have to think about we have to think about two things speed versus memory we typically care about like I typically care about runtime
speed like how fast my program runs versus memory because it's pretty easy for me to buy more RAM and throw it in a machine it's getting cheap cheaper RAM is pretty cheap I think we also have to talk about time versus space so when I say speed or memory
I'm actually talking about time and space so I think it is really interesting terms because I just think about Star Trek then like so we have Q representing time and Picard representing space for some reason I don't know I just whatever anyway so the
point is that space is not free because you know we may we may be able to add more memory to our machines but it's still not free it costs something it cost some RAM but time is also not free because maybe we want to serve up requests quickly and really
what the thing that the point of this is is that you know nothing is actually free we have to make a decision when we're trying to improve the performance of our systems whether we choose we choose Q or whether we choose Picard or there's actually
one there's one other thing that we can do we can find a better algorithm sometimes there's certain cases where we're able to improve both of these but I find that to be pretty rare we'll find it there's gonna be an example of that in my
slides we'll find we'll find a mythical unicorn in these slides but I think that this is a pretty rare rare thing that we can do so most of the time we're making trade-offs most of this talk will be making trade-offs and most of the time we're
gonna talk about giving up RAM for improving the speed of our system so RAM is cheap for us web developers sorry Heroku so we're gonna focus on runtime speed we're gonna focus on speed at the cost of RAM and the point that I'm trying to make here
is that time and space are related we can typically trade one for the other when we're talking about performance of our applications so the first thing I'm going to look at is performance tools so this this is basically the advertising section of my
presentation where I'm advertising other people's tools because I have no idea how to build this stuff I am just using it to make our code better so yes advertisement time so one of the tools that I like to look at for raw performance like first we're
gonna look at raw performance this is when we have like two two bits of code and we just want to know how they compare to each other with speed like which one of these is faster and my go-to tool for this is a gem called benchmark IPs and I'm going to
show you show you how to use that with your code but first we're gonna compare that to benchmark that comes with Ruby standard libraries this is a benchmarking tool that comes in Ruby standard library it looks exactly like this you say like create a new
benchmark and run some tests n times right you may have written you may have written a benchmark like this before now the problem is like if if you've written a benchmark like this before you might notice one of the problems is well how big do I make n
you'll sit there and you'll like say okay well maybe I may need to make a 10 or maybe I need to make it a thousand I'm not exactly sure so you run it and this may look pretty familiar to you you run it and it's like wow that's super fast
it took zero time well obviously it did not take zero time it probably took more than that your end was not large enough for you to study the performance of this study the performance of this method the other problem is that we have to deal with noise on our
machines like you might be sitting there running your bed tark's but you've also got iTunes going and Twitter running and that YouTube video as well like and you have the yang cats going trying to get that high score and this is costing a lot of noise
with your benchmarks so it'd be nice if you had some sort of standard deviation to tell you like hey this is it took it while at longest this amount of time and at least this amount of time so we can say it's kind of in the middle here and this is
where benchmark IPS comes in so what benchmark IPS says is like okay let's figure out the iterations per second that's where IPS comes from it says like okay how many how fast could I run this code in five seconds so we have an example here where we're
comparing set time how fast can we access a set versus how fast can we access an array like is this a member of an array or a member a member of a set and if we compare those we'll see that accessing the set is much faster over there on the right right
hand side we have iterations per second so we can say like the number the higher this number is the better it is how fast can we do that per second so set include is about I don't know some big number I'm not sure 30 bajillion and then is that a number
I don't know and then array dot include is like this which is smaller I can tell it's smaller because it's shorter fortunately I'm using the same size falling so since the set the set include is higher that means that using a set in this particular
example is better than using an array so the point to take home from this is for iterations for second higher is better just remember that higher is better the other important thing that this provides is a standard deviation so we can say like well if we if
we this at the slowest this could be 12% slower or 12% faster on either side of this particular number and the reason that this is important is maybe you've implemented some algorithm to different ways and you're not sure if one is faster than the
other maybe you run it one way and it seems faster but if you don't have this standard deviation it could just be noise in your system like maybe this time you're not watching you know YouTube videos and listening to iTunes when you run this benchmark
[ ... ]
Nota: se han omitido las otras 7.214 palabras de la transcripción completa para cumplir con las normas de «uso razonable» de YouTube.