Performance in Kotlin

Поділитися
Вставка
  • Опубліковано 14 січ 2025

КОМЕНТАРІ • 18

  • @ShubhamSinghMusic
    @ShubhamSinghMusic 27 днів тому +1

    I'd always loved using Kotlin's forEach method until I was told and I also read in some article that using the old ways of writing code is faster. Thank you for introducing me to the benchmark APIs. I won't take anyone just on their word anymore 😂

  • @arsildo
    @arsildo 3 місяці тому +4

    You are doing this youtube thing very nicely Sebastian 😆, catchy titles and good videos, good job mate

  • @robchr
    @robchr 3 місяці тому +3

    Also look at the bytecode

  • @theapache64
    @theapache64 3 місяці тому +3

    Quality content!! 👌

  • @xybnedasdd2930
    @xybnedasdd2930 3 місяці тому

    Additionally: your benchmark measures almost empty for loops. In practice, your for loop typically does several times more work inside than is taken up by the actual iteration (branch prediction + misses). So whatever difference there is, it is going to get massively reduced in practice with actual usage.

  • @chifi6852
    @chifi6852 2 місяці тому

    I didn’t know the existence of the method measure and the extension. Thanks for that!
    Also, how do you make the suggestion saying “Tab to complete” ?

  • @niketjain9829
    @niketjain9829 3 місяці тому

    Awesome stuff, learn lots of new things.

  • @coroutinedispatcher
    @coroutinedispatcher 3 місяці тому

    I thought that was because of the way Java allocates collection objects in memory, which is quite random if I am not mistaken. Without benchmarking, I believe you would be getting the same results if you try that in Java. Never tried it though, just a guess.
    In c++ I believe you won't have such problem, because of the different nature of arrays.

  • @DavidBreneisen
    @DavidBreneisen 3 місяці тому

    By using 100,000 iterations you are diluting the Iterator instantiation overhead. Maybe a better test would be to execute a (0..10) loop 10,000 times.

  • @PM-p9j
    @PM-p9j 3 місяці тому

    I've seen for these types of perf tests, you'll also get more accurate results if you warm up before you start measuring. If you don't do warm up, you'll generally see the first operations being slower than the last ones, skewing the results.

    • @PM-p9j
      @PM-p9j 3 місяці тому

      Whoops, should've watched a bit further before commenting...

  • @davidsiewert8649
    @davidsiewert8649 3 місяці тому

    The flickering of the blur near your head vs background is really distracting. Maybe just disable it instead?

  • @koteelok2014
    @koteelok2014 3 місяці тому

    Good vid bud

  • @SureshG
    @SureshG 3 місяці тому

    Nice one. I would also recommend this talk from Aleksey Shipilev ua-cam.com/video/x3Vlze1mUj4/v-deo.html , which explains this black hole and other black magic on JVM benchmarking.

  • @thanosfisherman
    @thanosfisherman 3 місяці тому +1

    If you care about performance just use a serious language like Rust🚀

    • @s.sellmair
      @s.sellmair  3 місяці тому +1

      Why so serious? 🃏