this is why your code is slow...

แชร์
ฝัง
  • เผยแพร่เมื่อ 13 ต.ค. 2024
  • In this video I show why your code can be slow and how to improve it. When writing code to production you need be careful.
    Don't Forget to
    ===========================================
    💯 Subscribe to Amigoscode - bit.ly/2HpF5V8
    💯 Courses Available for free here - amigoscode.com...
    💯 Join Private Facebook Group and Discord - amigoscode.com...
    ⭐ Table Of Contents ⭐
    ===========================================
    🙊 Here are the goods for all my videos video 🙊
    ► Recommended Books
    ===========================================
    Clean Code - amzn.to/2UGDPlX
    HTTP: The Definitive Guide - amzn.to/2JDVi8s
    Clean Architecture - amzn.to/2xOBNXW
    ► Computer and Monitor
    ===========================================
    New Apple MacBook Pro - amzn.to/3464Mmn
    Dell 27 INCH Ultrasharp U2719D Monitor - amzn.to/2xM3nW1
    Double Arm Stand Desk Mount - amzn.to/3aYKKfs
    USB C Hub Multiport Adapter - amzn.to/2Jz7NlL
    ► Camera Gear
    =============================================
    Sony ILCE7M3B Full Frame Mirrorless Camera - amzn.to/346QIJn
    Sigma 16 mm F1.4 DC DN - amzn.to/2wbic3Q
    Sigma 33B965 30 mm F1.4 DC DC - amzn.to/39G37Fd
    ► IDE & Tools I use for coding 💻 🎒
    ===========================================
    ITerm
    VsCode
    GoLand
    IntelliJ Ultimate
    Sublime
    P.S
    ===========================================
    💯 Don't forget to subscribe | bit.ly/2HpF5V8
    💯 Join Private Facebook Group and Discord - amigoscode.com...
    💯 Follow me on Instagram | bit.ly/2TSkA9w
    ❤️ Thanks for watching

ความคิดเห็น • 243

  • @TischTiger
    @TischTiger ปีที่แล้ว +27

    My first thought, not realizing which programming language this is, was that a loop is used here, although there is a mathematical solution to the problem that does not require a loop. So my first optimization would be to replace the loop with "Long sum = Integer.MAX_VALUE * (Integer.MAX_VALUE + 1) / 2;". But using objects where primitive data types are sufficient is also a good point.

    • @mrtnsnp
      @mrtnsnp ปีที่แล้ว +4

      In LLVM this is actually what the optimiser does (in O3). Of course not in Java, but plenty of other languages to choose from.

    • @corejake
      @corejake ปีที่แล้ว

      My first thought was the same, except just doing it in calc and then replacing the function with a constant result.

    • @mrtnsnp
      @mrtnsnp ปีที่แล้ว

      @@corejake The funny part is that llvm will optimize the code to the equivalent of (n-1)*n/2, so it does not pre-calculate the answer, but replace the loop with the correct mathematical expression. At first I thought it worked out a hard coded answer, so I compiled a program that takes n from the command-line.

    • @kenzostaelens1688
      @kenzostaelens1688 ปีที่แล้ว

      fun fact, (Integer.MAX_VALUE+1)/2 is exactly 2^32 so you could even shift Integer.MAX_VALUE by 32

  • @eugeneyap4208
    @eugeneyap4208 ปีที่แล้ว +8

    love the profiler demonstration to show the memory and cpu performance when running code. It really helps in visualization of how bad code vs good code perform

  • @donizetevida2149
    @donizetevida2149 ปีที่แล้ว +4

    *final* keyword on class is about inheritance not about immutable instance.
    Long should be on stack without a *new* keyword, like in C++.

  • @gulbalasalamov1367
    @gulbalasalamov1367 ปีที่แล้ว +54

    Thank you for demonstrating the improvement with graphs using profiler. That's pretty much more educational with visuals. I'm definitely going to use profiler tool too

    • @shadamethyst1258
      @shadamethyst1258 ปีที่แล้ว

      You need a good profiler to find the slow areas of code and you need benchmarks to confirm that what you are doing is actually improving things

  • @trustDproc3ss
    @trustDproc3ss ปีที่แล้ว +14

    Please make a video on profiling, it would be great adding that tool in my development. Thank you for this.

  • @nandorholozsnyak7799
    @nandorholozsnyak7799 ปีที่แล้ว +10

    Cool video, just a few notes:
    - I'm curious why is the method in the controller with the GetMapping is private? Are you trying to make sure that even if somebody would inject the controller class to another class they won't be able to call it? If yes interesting approach.
    - The Long class is not immutable because it has the "final" keyword in the class definition, it is an immutable class because the value it stores is marked as final. Code from the Long class: `private final long value;` - If it is final you can not change it after you initialized it, it can be a bit misleading.
    - GC will kick in when it has to, clearly the code with the boxing is inefficient but the GC will know when it should kick in and it will eliminate the unreferenced objects from the heap.
    - Using non-primitive types are having their own use cases, they can be null, so they can be representing missing or unset values, primitives can too, but it would require business modelling decisions, about which value will represent that the value is missing or not specified. (-1, 0?)
    - I'm really missing "proper" explanation about what is happening in the background, it is an important topic, but I just see a profiler, but where is the decompiled byte code or even the byte code itself? If anybody want to see the stuff that is happening in the background the "javap" tool must have been mentioned.
    It can describe the class file with all the byte code instructions. In the boxed version we will see virtual and static method invocations, where the boxed value is going to be converted to pure primitive type (longValue()), we will see that the integer is being casted to a long value and the result of the addition will be converted to Long with the valueOf static method. This is where the "magic" is happening, Java devs should be aware of this tool and should be using for these kind of purposes. With the primitive example there is no static or virtual method calls, only good old additions and store functions.
    - I'm not against Postman but IDEA is having a cool HTTP Client, that can generate HTTP (or even gRPC) requests and it can run them, if you need a tool to quickly execute HTTP requests I would recommend to try it out, such a cool feature.

  • @mostafamabrouk8806
    @mostafamabrouk8806 ปีที่แล้ว +4

    The profiler part was very good as I wanted something like that to keep track of performance. ❤

  • @amjoode2
    @amjoode2 ปีที่แล้ว +102

    Why use a loop for sequentially summing integers to n? Just multiply n with n +1 and divide them by 2,

    • @JorgetePanete
      @JorgetePanete ปีที่แล้ว +8

      the compiler actually does that, it's just an example

    • @rohankumartalreja
      @rohankumartalreja ปีที่แล้ว +10

      The compiler not does it.
      You have done it by yourself.
      See the profiling by yourself.

    • @markmyers2732
      @markmyers2732 ปีที่แล้ว +8

      This comment should be higher. There shouldn't be a loop in the code if there is a linear step to achieve the same result. Even if the compiler is believed to achieve the most efficient implementation under the hood.

    • @Ficolegend
      @Ficolegend ปีที่แล้ว +16

      Just an example. Advice here is very good.

    • @Erlisch1337
      @Erlisch1337 ปีที่แล้ว +3

      you sound like a StackOverflow:er .....never go full StackOverflow:er....

  • @gawwad4073
    @gawwad4073 ปีที่แล้ว +3

    Using primitives is a good idea in Java unless you have a reason to use the wrappers. In real programs you're not going to see performance differences like this though. Testing busy loops is just silly.
    Also the reason GC left that memory uncollected is to save resources. No point running cleanup if there is plenty of space left.

  • @doven_2750
    @doven_2750 ปีที่แล้ว +55

    Hello, AmigosCode. Can you please record a video about when should we use wrapper types instead of primitives? Thank you for the video :)

    • @cloudstackz
      @cloudstackz ปีที่แล้ว +13

      There isn't much that can be said here, but generally speaking, wrapper types are typically used when working with generic types or collections where you need to use null to represent the absence of a value.

    • @MrKozeljko
      @MrKozeljko ปีที่แล้ว +1

      @@cloudstackz And at least part is meant to be solved with Project Valhalla.

    • @HoD999x
      @HoD999x ปีที่แล้ว +3

      the question is not "when should you" but "when do you have to"

    • @CottidaeSEA
      @CottidaeSEA ปีที่แล้ว +1

      Optional works. Optional doesn't.
      If you then need to use the Long in a similar way to the video, you unwrap it to use a primitive.

    • @CesarScur
      @CesarScur ปีที่แล้ว

      In Martin Fowler's book, refactoring, he points out that you shouldn't prefer primitives unless it makes sense for the business. Using many primitives are usually a smell. It is recommend that you ponder about it and then replace with objects that reflect the business better.
      These types of simplifications that deal with abstract code is usually bad. In reality we don't see code like this very often. Instead we look clients or items in a order and so on. The size is very different and the gains vs sacrifice made is not worth. What is the point in making a 100ms request faster by 0,001ms?
      I recommend reading the first 2 chapters of refactoring.

  • @cesarvalencia6191
    @cesarvalencia6191 ปีที่แล้ว +10

    As always, very educational and I always learn something new from your videos. a demo on Profiling would be great.

  • @nightfox6738
    @nightfox6738 ปีที่แล้ว +1

    Reducing memory allocations is definitely a huge one but I think the most important thing to minimize is branches. Particularly loops. In this example for instance, you could use gauss's equation instead of a loop altogether ( n(n+1)/2 ) and while this is a very specific example, its important whenever you're using a loop to think "Do I really need a loop here?"

    • @petitmoi735
      @petitmoi735 ปีที่แล้ว

      what do you mean by that ?

    • @nightfox6738
      @nightfox6738 ปีที่แล้ว

      @@petitmoi735 I thought the comment was pretty straightforward what part didn't you understand?

    • @matheusjahnke8643
      @matheusjahnke8643 ปีที่แล้ว +3

      @@petitmoi735 instead of calculating
      S=0+1+2+3+...+n
      With n additions
      You do
      S=n(n+1)/2
      The legend says that a teacher didn't want to deal with children... so he told them to sum 1 to 100...
      Unfortunately for him, little Gauss was in class... and knew the formula instead of brute forcing the result...

    • @matheusjahnke8643
      @matheusjahnke8643 ปีที่แล้ว

      I mean, this optimization turns O(n) into O(1).
      But you should be careful to check if the result doesn't overflow.

    • @nightfox6738
      @nightfox6738 ปีที่แล้ว +1

      @@matheusjahnke8643 absolutely, but if the result overflows in the optimization, it overflows on the original too.

  • @imblackmagic1209
    @imblackmagic1209 ปีที่แล้ว +1

    thanks, this also applies to other languages, it's always better to use the basic types
    that aside, the example can be done in O(1) as there's a formula for the sum of the first n numbers, but i recognize that's not the point of the video

  • @MrJgremmen
    @MrJgremmen ปีที่แล้ว

    Nice! I understand the code is just an example for demonstration purposes. The biggest takeaway is to be aware that primitives are faster than their boxed representation and creating massive amounts of objects on the heap within loops is a no-go. Someone already mentioned that this particular problem could be solved mathematically. It is worth mentioning something like this because there are lazy developers out there running loops or producing lots of code for things that can be done faster/easier. To even optimize the example code further, I would change the loop variable from long to int. I'm not sure if it will be noticeable in the end but it is cleaner and requires less memory accesses.

  • @Yotanido
    @Yotanido ปีที่แล้ว

    Something I found very interesting: I used a very similar piece of code to do some performance testing in Rust.
    Turns out, the compiler can actually optimise away the entire loop and just replace it with a maths expression.
    Like, I knew how to do it myself, but that the compiler could just do that blew my mind.

  • @aminesafi7261
    @aminesafi7261 ปีที่แล้ว +4

    Excellent video, you explain things in a very simple way.
    Many thanks and keep going 💪🏻

  • @Vladimir_Java_dev
    @Vladimir_Java_dev ปีที่แล้ว

    As I understand, we have to use 'wrapper' classes only for cases where we use generics such as collection. In other cases it is more preferable to use primitives as is.

  • @andrejtrozic509
    @andrejtrozic509 ปีที่แล้ว

    Best Java programming teacher on TH-cam.

  • @daichiakiba5701
    @daichiakiba5701 ปีที่แล้ว

    It's very helpful! Which profiler tool are you using?

  • @miloplayz5264
    @miloplayz5264 ปีที่แล้ว

    Salam AmigosCode, Thanks for all your content you are doing! I wish you a very well Ramadan month!

  • @damianjoel5833
    @damianjoel5833 ปีที่แล้ว +1

    You are the best bro, thanks a lot for all your videos!

  • @SuperKidontheblock
    @SuperKidontheblock ปีที่แล้ว

    Profiles are very underused. Advocating for more people to use them especially when creating webserbices

  • @amirulidzham
    @amirulidzham ปีที่แล้ว

    Thanks brother for the tips. Ramdan Kareem brother, happy fasting...

  • @tomaszvinys2389
    @tomaszvinys2389 ปีที่แล้ว

    Man, Thank You so much for showing this! I'm missing for java such java performance tutorials a lot. I'd love to see more of videos like this one.

  • @nikolanaydenov2157
    @nikolanaydenov2157 ปีที่แล้ว +3

    Can you please explain when we should use the wrapper classes instead of the primitive data types?

    • @Misfiring89
      @Misfiring89 ปีที่แล้ว +1

      Always use primitive types when possible, but there'll be scenarios where wrapper classes are needed:
      1. Collections like lists, sets and maps. They require objects and thus you have to use wrapper classes.
      2. You need null values which are not representable with 0, for example as a return type.
      3. Accurate representation of decimals, e.g. Big Decimal

  • @lighttheoryllc4337
    @lighttheoryllc4337 ปีที่แล้ว +1

    😂 I don't need no hook on this beat, all I need is the CODE in the background, my headphone high, and da connect on da mic Yep!

  • @sadeepaalwis5938
    @sadeepaalwis5938 ปีที่แล้ว +2

    Thank you for the awesome video. please consider making a video about profiling also does it have a specific IntelliJ version to get the profiler. i checked on mine but that option wasn't available

  • @rajkhare5949
    @rajkhare5949 ปีที่แล้ว +2

    very good video...got to know the difference between the wrapper and primitive use in real-time...please make the video on the profiler too so we can understand how to use this tool for our code performance improvement!!!

  • @tairovich.solutions
    @tairovich.solutions ปีที่แล้ว

    Brother, if you don't mind me asking, what application do you use to record your screen and yourself? Also how do you make that circle video of yourself? Thank you

  • @alexandresantos7966
    @alexandresantos7966 ปีที่แล้ว +1

    What situation do you think that's better to use wrapper class?

  • @Starchaser38
    @Starchaser38 ปีที่แล้ว +3

    So, since Long is immutable, every time "sum += i" is invoked it re-creates the object anew??? Oh God... 😅

    • @Erlisch1337
      @Erlisch1337 ปีที่แล้ว +2

      wait until you hear of strings....

  • @pradeepkumardodda6109
    @pradeepkumardodda6109 ปีที่แล้ว

    Thank you for your efforts, I request you to do more videos like this, which helps to improve the code

  • @xxkelel20xx
    @xxkelel20xx ปีที่แล้ว

    I learn something new everyday in my programming journey!

  • @deorgeneslorddj
    @deorgeneslorddj ปีที่แล้ว +1

    Please make a video about profiling. It was incridible!

  • @ankitkadam8161
    @ankitkadam8161 ปีที่แล้ว +4

    Which plugin are you using in intellij for checking memory graphs?

    • @MrJgremmen
      @MrJgremmen ปีที่แล้ว

      The IntelliJ Profiler is (as the name sort of gives it away) part of IntelliJ.

  • @sweetphilly2
    @sweetphilly2 ปีที่แล้ว

    Damn that was informative. That illustration of call and memory stack and heap is clean af too - super easy to understand

  • @som3ah0
    @som3ah0 ปีที่แล้ว

    Thank AmigosCode for demonstrating the improvement using profiler.... jazak allah khair ... please we want more about profiler

  • @jatindersinghaujla
    @jatindersinghaujla ปีที่แล้ว

    Then where we should use primitive and warapper classes.
    Primitives I can say to use when doing some calculation in a loop. But when to use wrapper classes.

  • @lanceareadbhar
    @lanceareadbhar ปีที่แล้ว +7

    I first read this as this is why you code slow?

  • @raymondsam5642
    @raymondsam5642 ปีที่แล้ว +1

    Thank you for the information. Good job.
    A tutorial on profiling would be fantastic.

  • @Sasikumar-kr7xy
    @Sasikumar-kr7xy ปีที่แล้ว +1

    Thanks for the demo on performance using profiler. Please do a dedicated on profiler

  • @CesarScur
    @CesarScur ปีที่แล้ว +1

    I think the advice could be nuanced. In general there is no significant impact in performance because loops rarely in the 2147483647 scale, so you shouldn't always prefer primitives alas you want to incur in the primitive obsession smell. However one should be mindful IF dealing with large scale like looping 2147483647 items.
    I prefer the way Martin Fowler lays this out (in my words): one should prioritize a well factored code over a performer code for it is easy to waste time optimizing unnecessarily and optimization is much easier to achieve on a well factored code than a code written to be performative. Exception being time critical application the likes that are designed with alloted time from the beginning.
    Hope this was a helpful input.

  • @CottidaeSEA
    @CottidaeSEA ปีที่แล้ว

    This is why pure functions can be extremely costly as well. Know when and when not to use immutable data.

  • @justindouglas3659
    @justindouglas3659 ปีที่แล้ว +1

    Yes bro you should make a vid on profiling and i hope one day junit cuz i don't know a thing about it or maybe security tools tjat would be nice

  • @amiganer681130
    @amiganer681130 ปีที่แล้ว

    The sum of 1...n with n in N (all natural numbers) is "n*(n+1)" -> You get 1 caculation for this for every n.

  • @MykhailoKolotailo
    @MykhailoKolotailo ปีที่แล้ว

    Thx, it's important to know. I didn't think about this before watching this video. Your's videos helping me know more about Java. Make more like that)

  • @FahimHoqueArnob
    @FahimHoqueArnob ปีที่แล้ว +4

    Hey already posted this idea on discord but can you do a video on securing spring boot application with firebase or Auth0?
    Securing a service is crucial and rather than investing time on auth manually and test the mechanism I think it’s better to depend on proven platforms to secure the applications in some cases

  • @gosnooky
    @gosnooky ปีที่แล้ว

    Problem is, so many tutorials and teachers out there say long and Long are interchangeable. This is clearly not the case.

    • @MrJgremmen
      @MrJgremmen ปีที่แล้ว

      They are if you don't care about performance and memory usage. The problem is the auto(un)boxing feature. It makes the code more readable but also hides NPE and heap pollution problems. Using an IDE like IntelliJ can be a great help to detect problems like that.

  • @Nezar-hb6vu
    @Nezar-hb6vu ปีที่แล้ว

    Great stuff, by the way, are you gonna start a Domain Driven Design tutorial any soon

  • @Speiger
    @Speiger ปีที่แล้ว +3

    Just found this channel. Looked at the performance improvement you did, looked solid from experience.
    Look at your other videos suggesting STREAMS over FOR LOOPS and thought, lets hope he makes a video where he redacts that statement since for loops are way faster then streams since streams build a entire state machine instead of simple iterators xD
    (Note: I am writing performance collection libaries xD)

  • @azharponani
    @azharponani ปีที่แล้ว

    What is the usecase of using long and Long..how can we decide when to use which

  • @ryanquinn1257
    @ryanquinn1257 ปีที่แล้ว

    I don’t know why I laughed at the garbage collector being a gun off to the side

  • @debasishraychawdhuri
    @debasishraychawdhuri ปีที่แล้ว

    Bad example anyway, you should use the formula - it will be way faster. 1+2+...+n = n(n+1)/2.
    Algorithm: if (n & 1 == 0) {m=n+1; n>>1; return n*n}else{m= (n+1)>>1; return m*n}

  • @semilife
    @semilife ปีที่แล้ว

    Thanks once again. A video on profiling would be nice, I am new to IntelliJ coming from eclipse.

  • @cirates
    @cirates ปีที่แล้ว +2

    Summary: If you can use primitive types, use that. Do not waste your memory with Wrapper

  • @UsernameUsername0000
    @UsernameUsername0000 ปีที่แล้ว

    Extremely insightful but I feel like it could’ve clicked better if you quickly pointed out why so many objects were being created (I’m assuming it’s the immutability of Long).

  • @astolfohsu
    @astolfohsu 8 หลายเดือนก่อน

    I think ,this Long type can replace to long , it's beautiful transalte

  • @alexis9314
    @alexis9314 ปีที่แล้ว

    Thanks for showing the improvement and how to work it!

  • @Coders_World
    @Coders_World 2 หลายเดือนก่อน

    Non Only Memory. But i guess it will improve speed because of reduced Operations of Autoboxing unboxing as well. Right ?

  • @aliakseydruzik7433
    @aliakseydruzik7433 ปีที่แล้ว

    Also is important to understand how static-keyword works.

  • @dngrz
    @dngrz ปีที่แล้ว

    Excelent! I Will try! Good improvement ! Thank You a Lot 👍

  • @rajsundarlogasundaram1596
    @rajsundarlogasundaram1596 ปีที่แล้ว

    Meticulous catch here in our day to today code block... Kudos dude

  • @blakvein
    @blakvein ปีที่แล้ว +2

    First performance issue is that you are using for loop to calculate sum instead of calculating it with just one operation using formula.
    But I get that this is for sake of demonstration ;)

  • @eduardomatos666
    @eduardomatos666 ปีที่แล้ว +2

    Awesome!! Please create more videos like that 😍😍

  • @muhammedahmed1514
    @muhammedahmed1514 ปีที่แล้ว

    Assalamu Alaikum.
    Very informative video. Thank you.
    I have a question, when should we use wrapper classes then?

    • @ДмитрийФ-г3л
      @ДмитрийФ-г3л ปีที่แล้ว +2

      In DTOs for example. Everywhere, where you need a Serialization.

    • @lukmanmudi5742
      @lukmanmudi5742 ปีที่แล้ว +3

      Use wrapper classes where a null value has a meaning i.e. If based on your domain requirement when age is set to null it means age is not set (age does not apply here) but when age is set to 0 or a positive integer age applies and is set.
      Also one major use of wrapper types is when working with Generics. Generics does not allow the type to be a primitive so instead of int use Integer. As for their use in DTOs I don't think that is what they are meant for. Feel free to use either primitives or wrapper types in DTOs as it suits you.
      Lastly remember wrapper types are reference types and therefore require more memory than primitive types. Your first resort should be to use primitive types unless when necessary.

    • @lukmanmudi5742
      @lukmanmudi5742 ปีที่แล้ว +1

      Wa alaikumussalam wa rahmatullah

    • @rohankumartalreja
      @rohankumartalreja ปีที่แล้ว +1

      When you are performing operation on data, use primitive else wrapper classes.

    • @yuriastoria1477
      @yuriastoria1477 ปีที่แล้ว

      @@lukmanmudi5742 syukron jazakallah khairan...your explanation shed some light for me understanding when we use wrapper or primitive....

  • @pollafattah7062
    @pollafattah7062 ปีที่แล้ว

    Yes Please have a video about profiling, actually Can you please have a video series about the intellij and all interesting features. I will show them to my studens.

  • @salihiyassine2355
    @salihiyassine2355 ปีที่แล้ว

    thank you so much, yes could u make another video about profiler?

  • @zhandosyernazarov3086
    @zhandosyernazarov3086 ปีที่แล้ว

    Assalamu alaikum, thank you for the video, this was something new for me. Even though I've been using Intellij for a long time, I did not know about profiler.

  • @rusty_screw
    @rusty_screw ปีที่แล้ว

    Hi, when you mentioned that class Long is final you confused immutability with "finality"(ability to extend a class)

  • @lighttheoryllc4337
    @lighttheoryllc4337 ปีที่แล้ว +1

    Lyrics ( Let's go uh, Let's go uh.. ya... Cause I got wat it takes ta make mic goo.. ba ba dun...
    (Dip set instrumental 😅)

  • @khalilromdhani
    @khalilromdhani ปีที่แล้ว

    Hello, AmigosCode. Can you please record a video about design pattern

  • @networkingknowledge6261
    @networkingknowledge6261 ปีที่แล้ว

    thx for the great tip , we want pliz a full video pliz !! , thx a lot

  • @KAFJHON
    @KAFJHON ปีที่แล้ว +1

    HI AmigosCode, I have been binge watching your tutorial videos for the last week or so, and I was wondering why you used wrapper classes instead of primitives on your tutorials, I'm a bit confused about this one, if you could please explain further when to use one or another, or is it a personal preference.
    Thank you in advance
    excelent video as always

  • @mahmoudchebbani4807
    @mahmoudchebbani4807 ปีที่แล้ว

    A video on profiling would be amazing!

  • @furkanbbcn
    @furkanbbcn ปีที่แล้ว

    Thank you for the information. Good job.

  • @dmytro4312
    @dmytro4312 ปีที่แล้ว

    Hi, yes, it will be very interesting to hear about profiler

  • @jobryahov6585
    @jobryahov6585 ปีที่แล้ว

    Crazy examples😅 Don't repeat that problems guys😊 First, you are thinking, planning. Second, do it!

  • @jakubbanik7622
    @jakubbanik7622 ปีที่แล้ว

    Havent watched video... but i will answer your question... what is problem with this code.. First of all it could be static method. is way faster and i code could be optimilized way better then anonymous method. Cost of executing lambda is higher and sout is expensive operation too.

  • @kchemutai3483
    @kchemutai3483 ปีที่แล้ว

    Very informative. Thanks amigos code

  • @Synkto01
    @Synkto01 ปีที่แล้ว

    Amazing, yes pls teach us about profiling and how to undertanding

  • @aspergerhyperactive
    @aspergerhyperactive ปีที่แล้ว

    how to design a programming language and which programming language should be used to design a programming language

  • @bernizhel
    @bernizhel ปีที่แล้ว

    I would like to see how to profile java programs, thanks for the video!

  • @HoliakaDmytro
    @HoliakaDmytro ปีที่แล้ว

    What theme was used in Intellij Idea in this video, isn't it new UI?

  • @dmitrik4610
    @dmitrik4610 ปีที่แล้ว

    Hi. you also can use object of AtomicLong class.

  • @yimyang-p1v
    @yimyang-p1v ปีที่แล้ว

    Hi,Amigoscode,thank you for the video, I am very interested in how to use profile tool

  • @Yutaro-Yoshii
    @Yutaro-Yoshii ปีที่แล้ว

    Is there any valid reason to use `Long`?

  • @dcorralf
    @dcorralf ปีที่แล้ว +1

    Hi, thanks for the content, it's a great video about performance. For my, maybe it will be interesting to make more videos about applications performance and the profile option of IntelliJ.

  • @neiliusflavius
    @neiliusflavius ปีที่แล้ว

    To me (as someone not very familiar with Java) it seems bad design to have the primitive and the object only differing in name by a single capital letter.

  • @techspeechplus582
    @techspeechplus582 ปีที่แล้ว

    Thank you for the explanation and it was helpful

  • @AleksandarT10
    @AleksandarT10 ปีที่แล้ว

    What about the stack? Isnt there a care where the stack can get full and cause stackoverflow?

    • @johnnyf1624
      @johnnyf1624 ปีที่แล้ว

      one scenario is a recursive function call itself w/o base will cause stackoverflow

  • @sandipgadade3735
    @sandipgadade3735 ปีที่แล้ว +1

    Are you full time youtuber??

  • @mathiasbartl9393
    @mathiasbartl9393 ปีที่แล้ว

    The sum of all integers < n has a closed form that you learn in school. Replacing an inefficient algorithm comes first.

  • @UberDurable
    @UberDurable ปีที่แล้ว

    Very useful, thanks!

  • @gbh1998
    @gbh1998 ปีที่แล้ว

    Viewers please don't analyse the code posted in the thumbnail to check why it's slow, because the thumbnail code is the correct and efficient one!😁 Watch the video to get the clarity

  • @mohammedtahasindoli5643
    @mohammedtahasindoli5643 ปีที่แล้ว

    I would like to see a video on profiling, please take this request into consideration

  • @Alptugaydin
    @Alptugaydin ปีที่แล้ว +1

    That was definitely impressive. I would like to see more videos, especially involving resource optimization, and profiler. You are doing great, thanks

  • @creepymuffin2351
    @creepymuffin2351 ปีที่แล้ว

    Thanks, that is a really good advice!

  • @jihedbouchnak
    @jihedbouchnak ปีที่แล้ว

    i will love to see more video a bout clean code an optimisations good job

  • @ahmede7141
    @ahmede7141 ปีที่แล้ว

    Thanks, and please do more of this type of content please

  • @starkhunt2684
    @starkhunt2684 ปีที่แล้ว

    Please tell us more about profiling