And some retards still believe the compiler will optimize everything for you.
>>106960353ok but span is safer
How does span work under the hood?Is it like range in Python, where it creates a list that you then iterate over?
>>106960353Because you construct the span every loop. Retard
>>106960353Did you turn compiler optimizations on?
>>106960882Why can't our friend the clever compiler optimize it out?
>>106960882no?
>>106960353>meme "problems"the only thing more retarded than sepples are those
>>106960353Rust doesn't have this problem.running 3 teststest tests::bench_fast ... bench: 4,499.43 ns/iter (+/- 95.62)test tests::bench_idiomatic ... bench: 4,482.95 ns/iter (+/- 46.71)test tests::bench_slow ... bench: 4,501.73 ns/iter (+/- 10.81)
running 3 teststest tests::bench_fast ... bench: 4,499.43 ns/iter (+/- 95.62)test tests::bench_idiomatic ... bench: 4,482.95 ns/iter (+/- 46.71)test tests::bench_slow ... bench: 4,501.73 ns/iter (+/- 10.81)
>>106960911compiler devs and sepples committee talk big talk but can't walk the walk as usual>brooo our compiler is super smart giga AI powered advanced algorithms and can optimize everything>muh premature optimization is... LE ROOT OF ALL EVIL, o algo>Muh sepples zero cost abstractions n'shiiieet
>>106961306Stop speaking like a nigger.
>>106960353>spans suckalmost like most shitty C++ features and their implementations are malicious compliance.
>>106961312ay yo man, i ain't a real nigga like yo pops, i's just be talkin like one cuz dem racis-ass crackas on 4chan start hootin' and hollerin' when i do. don't mind me cuh, i's be white as snow, y'gnomesayin? iss all coo, mane.
>>106961303based and idiomatic pilled. how will sepples sissies cope with this SAFE AND BEAUTIFUL implementation?
>>106961306>o algowtf does this even mean?
>>106961360O almighty god of ALGOrithms, O Algo!>>106961303>short and simple code that gives the exact same result compiling to a different assemblyMuh llvm is sooooo advanced o algo
>>106961377>>short and simple code that gives the exact same result compiling to a different assemblyConsidering the speed is equal, this does not matter. Previous versions of Rust(eg 1.65) compiled it to the exact same machine code, but somewhere along the way they changed how this kind of code gets optimized and now iterators get inlined differently than ranges. There is still no measurable difference in performance.
>>106961401It does matter because the code in the first window creates longer and probably larger assembly code. If they could shrink down the assembly without affecting performance, why not do that?
>>106961360or something in beanspeak o algo
>>106961423>If they could shrink down the assembly without affecting performance, why not do that?Because compiler only knows limited set of optimizations it can do in reasonable time, and these optimizations have to be universal enough to work on wide range of different platforms and architectures. These snippets of code generate IR distinct enough to trigger different kinds of optimizations which result in slightly different machine code.If you want to learn more, you can use godbolt optimization pipeline analysis and look at it step by step too see what exactly happened, but I personally do not care enough to go through all of this.
yet another "forgot to turn on optimizations" threadbut yeah it's annoying that C++ is basically unusable with -O0
>>106960353I don't get it. What causes this? The possibility of arr/cnt changing mid-loop? But the loop did eat breakfast...
>>106961303
>>106961559>twitter e-celebBuy an ad and I might consider reading what you have to say.
>>106961559>gnu c/c++ versionsGNU coreutils are (almost) 100% C. Sepplesfags just won't shy away from cultural appropriation.
>>106961559do people who post this realize how low IQ they are?You can easily write something in some higher level langauge like javascript and shit all over some cnile diarhea purely because your algorithm actually uses a proper hashmap. All this shows is that gnu coreutils took over decades of effort to highly optimize specific cases that a relatively new project hasn't yet.
>>106960911Because it might have side effects, which would then modify the program behavior
>>106961572>>106961577
>>106961579Why can't our friend the clever compiler figure this out?
>>106961577>You can easily write something in some higher level langauge like javascript and shit all over some cnile diarhea purely because your algorithm actually uses a proper hashmapWhat makes you think the C versions use bad algorithms?
>>106960353You're doing it wrong.Span is used to eliminate the unsafe aspect of such crusty C-style code. Use it to wrap the arrays directly back at the caller, then pass and use that span in functions safely. Simple as.
>>106961604I didn't say that? are you those retards who fall for the>How would you feel if you didn't have breakfast?shit? low IQ nigger. learn how to read.
>>106961604What makes you reply to a Rust troon spouting nonsense, with even more nonsense? Only reason I can think of is that you're another Rust troon (or samefagging) and trying to create a pretext for more Rustroon rhetoric to be spouted.
lol
>>106961587Ok, so what are you even trying to say by posting some random article?If you are suggesting that the code I posted does not in fact sums the array, then you gotta argue it in better way than post an unrelated article about some unrelated project having unrelated problems.
>>106961616it isn't nonsenseafter the gzdoom drama, I found out abouthttps://github.com/Helion-Engine/Helionwhich shits all over all the cnile engines and it's written in C#.language implementation isn't that important for performance in most cases.
Reminder to ignore deranged Rust rhetoric and simply post Rust facts (>>106961629 >>106961587 >>106961559) instead.
>>106961616Meds. Now.
>>106961613What was the point of your post then?
>>106961629Yet another cnile forced to cope with fake graphs. It's like they don't even do basic fact checking and just fall for literal twitter troll in a desperate attempt to save their face lmao.https://x.com/kai_fall/status/1966158913478566093https://desuarchive.org/g/search/image/lpefOq3EscbItb7-JhCzyw/
>>106961587>>106961559lol. imagine trying to clone existing, documented, open source software and failing this hard. now imagine if they had to actually invent it from scratch
>>106961559>luncuck
>>106961821>imagine trying to clone existing, documented, open source software and failing this hardBecause project like wayland, pulseaudio, systemd, bash and even linux itself never had compatibility problems with their predecessors, right?
>>106961899>project like wayland, pulseaudio, systemd, bash and even linux itselfwhich reference implementations were they trying (and miserably failing) to clone?
>>106961552the span version compiles to comparison to end pointerint *end = arr + cnt;while (arr != end) { s += *arr; arr += 1;}seriously doubt this is 60% slower. OP probably just forgot to turn on optimizations so the span methods were not inlined
int *end = arr + cnt;while (arr != end) { s += *arr; arr += 1;}
>>106961925Wayland => xord, pulseaudio => OSS, systemd => init+many more, bash => Bourne Shell, linux => unixOver the years, all of them suffered numerous incompatibilities with the projects/systems they tried to replace
>>106960353kek so it is not just in js - other languages has this too.in js every loop perform slightly differently.for example negative loops are faster than positive ones.
>>106961971>xord*xorg
>>106961971the level of cope in this post is mindblowing. thanks for demonstrating why your community will never be taken seriously
>>106961997>thanks for demonstrating why your community will never be taken seriouslyOnly retarded normalfags do not take it seriously. Entire internet runs on Linux.
>>106962012ok, this is obviously a bot with a 200 token context window
>>106961982I wonder if the negative loop is so fast because it crashes on first iteration due to failed bound check
>>106961982Isn't reverse looping faster in all languages? Something to do with not having to check against the length or something? Also --i is better than i-- I think but that's probably optimized out.
>>106961982>200 iterations per secondwhoa
>>106962043Shouldn't the condition be evaluated before the first iteration?
>>106961958Test it yourself and you'll see.
Why does none of you ever look at godbolt.
>>106962091actually tried it and the end-pointer and span version is 60% faster, not slower
>>106962498that's -Og. on -O3 all are the same
>>106960447The tranny complex. Has to have safe sex because of dilation, now wants to force everyone else to do it too.
>>106960353speaking of compiling; on Gnu/Linux. I'm working on an experiment to try to compile a huge 30k line program on a cellphone. The program compiles just fine and works as expected on a desktop. It will probabbly compile on a cellphone running linux, and I'm curious about this as a stress test for the phone. Phone has 4 Gig of ram and 512 ssd. Any ideas or inputs would be appreciated.>Please wait a while before making a postwhy?
>>106962231GCC generates slightly different code.
>>106960353i have literally never heard about this or seen it used.
>>106960910>>106961532Man, people really just want to avoid this huh?
>>106964820Yeah I tried that code in godbolt it was essentially the same with O2 and O3.
>>106960353I have no idea what span is or does, sorry.
C++ = proven and tested tech for decadesRust = tranny shit
Do it properly (by not creating and destroying a fucking object in every iteration of the loop) and you will see that it's as fast as the C-style arrays in an optimized build.C-style arrays win in unoptimized builds though.https://quick-bench.com/q/QhGzLYaQJ9SL-BZpmdMSKWP1IZI
>>106961982As a developer, my time is more valuable than your CPU cycles.
>>106961629This is actually a graph of the average IQ of the programmers.
>>106961559buy an ad jewish niggerfaggot
>>106961303Now lets see the compilation times!
>>106960353never trust a retard to microbenchmark. that 60% might as well be pulled out of your ass.
>>106962498>>106962518retard wrecked again (this is not the first time OP has made a thread for this. he suffers from c++ derangement syndrome.)
>>1069620440 is the most often compared against number, so comparing against 0 is faster than ither numbers on most hardware
>>106962231where is the compiler output for slow()? why are you looking at the same output window twice? are you stupid or just dishonest?
>>106965418this is why you're being replaced by indians
>>106961423The part that does the addition is practically identical. The rest is barely different, not enough to show up in any workload
>>106961629This is the same guy who made this graph btw
>>106960353> function calls are slowerYeah no shit, function calls incur overhead. Are you actually retarded?
>>106970203>function calls incur overheadThat's not the problem here, and not all function calls incur overhead
>>106970379Shutup cnt.
>>106970572Nocoder kvetching
i don't get the obsession with rust in particular
>>106965279Wait, where is it destroying an object in the loop iteration?
>>106969371>where is the compiler output for slow()? why are you looking at the same output window twice?Because I attached compiled to the same source code twice by accident duh.>are you just dishonest?Yeah because I am a committee-paid shill trying to trick people into using std::span or some other shit lmao.
>>106971351to be also fair, you're using a nightly of clang as well
>>106971824Feel free to use any other compiler.
>>106961579>just solve the halting problem bro
>>106960353int cunt