[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip / qa] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


Where are you going to move the goal posts to now?
>>
goal
>>
>>101548754
I just goalposted in your thread, now what?
>>
>>101548754
I don't know what you are talking to but you probably don't want to use strcat like this if you want speed
A quick remedy would be for this case would be
strcat(&output[i * 13], "hello, world!");

instead of your current strcat line.
>>
File: 1717087988281832.jpg (275 KB, 1136x2048)
275 KB
275 KB JPG
Holy shit hahaha this fucking midwit is still at it lol
>>
File: 57b.png (690 KB, 1152x675)
690 KB
690 KB PNG
>>101548888
You can't do this to me.
>>
greeter greets customer like once
>>
>>101548754
Sar, you have not done the needful sar:
Why are you not doing the needful??

for (...) printf("good morning sir\n");
>>
>>101548942
I have a degree in your mum's vagana
>>
>>101548754
ad " \n" to the end of hello world
>>
File: IMG_1685.jpg (2.39 MB, 3000x3600)
2.39 MB
2.39 MB JPG
>>101548754
in case you're retarded enough to not know, your code keeps running strlen under the hood making it O(n^2)
>inb4 free
its gonna exit 0.02ms later

#include<stdint.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(){
int64_t i=1e6;char const *s="retard";char *a,*b=malloc(__builtin_strlen(s)*i+1);a=b;while (i--) a=stpcpy(a,s);puts(b);}
>>
>>101549015
BEHNCHOD YOU!
>>
>>101549103
Compiler flags?
>>
>>101549117
gcc -sir
>>
>>101548942
sex
>but it's a ma-
SEX
>>
File: overcomplice.png (30 KB, 1424x330)
30 KB
30 KB PNG
>>101548754
i get paid to overcomplicate things
>>
>>101548754
post compiler flags
I had better not see -O0 -g in them you retard
>>
#include <stdio.h>
#include <stdlib.h>

int main() {

const char *target = "Hello, World!";
const size_t target_len = 13;
char *output = malloc(1000000 * target_len + 1);

for (int i = 0; i < 1000000 * target_len; i+=target_len) {
for (int j = 0; j < target_len; j++) {
output[i + j] = target[j];
}
}
output[1000000 * target_len] = '\0';
printf("%s\n", output);

free(output);

return 0;
}


compile with -O2 or 3
>>
File: 1568190152664.png (259 KB, 693x601)
259 KB
259 KB PNG
macro_rules! rep {
($t:expr) => { concat!($t, $t, $t, $t, $t, $t, $t, $t, $t, $t) };
}

fn main() {
println!(rep!(rep!(rep!(rep!(rep!(rep!("hello, world!")))))));
}


real    0m0.122s
user 0m0.000s
sys 0m0.035s
>>
>>101549260
sir, the submitted code lacks proper bound checks
>>
>>101548888
witnessed
>>
>>101549538
And this... is to go even further beyond!

use std::io::Write;

macro_rules! rep {
($t:expr) => { concat!($t, $t, $t, $t, $t, $t, $t, $t, $t, $t) };
}

fn main() {
let mut stdout = std::io::stdout().lock();
let _ = writeln!(stdout, rep!(rep!(rep!(rep!(rep!(rep!("hello, world!")))))));
}


real    0m0.083s
user 0m0.000s
sys 0m0.033s
>>
>>101549538
Unholy based. I love rust macros now.
>>
>>101549538
>>101549599
I will not transition, I am saar.
>>
>>101549554
Dear Anon Sir,

The code works as intended, sir.
>>
#include <ranges>
#include <array>
#include <algorithm>
#include <iostream>
#include <ranges>
#include <utility>
#include <utility>

int main()
{
std::array<char, 1000*13> buf;
#pragma omp parallel for schedule(static)
for (std::size_t i = 0; i < 1000; ++i)
{
std::copy_n("Hello, world ", 13, buf.data()+i*13);
}

for (const auto _ : std::ranges::iota_view{0, 100})
{
[&]<auto... i>(std::index_sequence<i...>)
{
((std::cout.write(buf.data(), buf.size()), i), ...);
}(std::make_index_sequence<10>{});
}
}


g++ -std=c++20 -fopenmp a.cpp -O3 && time ./a.out
./a.out 0.05s user 0.10s system 45% cpu 0.345 total


It mostly depends on your terminal speed thoughbeit



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.