New answers tagged

0

brainfuck, 30*971956224/621731~46899.2 >+[>+[<]>->+]++++++++++<[.>.<] Try it online! The BF JIT that I'm using prints each character in a separate syscall. An implementation that coalesces multiple . commands into one syscall would likely perform better. Thanks to the list of BF constants.


1

Scala Simple Implementation (using mutable.Map) val map = scala.collection.mutable.Map.empty[String, Int] def wordsFromFile(filePath: String) = { val file = scala.io.Source.fromFile(filePath) val regex = "[a-z]+".r() file .getLines() .flatMap(line => (regex findAllIn line.toLowerCase)) .foreach { word => ...


6

[Rust] Optimized version of test9753's code I changed a few details (e.g. pre-processing the data and splitting up the parent links from child links) while also making the code a bit more idiomatic. On my machine this runs the giganovel about 20% faster. use std::env; use std::io::{Error, ErrorKind}; type Pointer = i32; type Count = i32; type Char = u8; ...


3

RUST Hashmap with FNV hasher Managed to get around ~95% of the top performer's performance without a custom data structure by just using a good hashmap. EDIT: This doesn't scale well to giganovel - which it is performing much worse on (2-3 times slower). ❯ time "./target/release/current ulysses64.txt 10" Benchmark #1: ./target/release/current ulysses64....


5

Rust translation of ShreevatsaR's "Faster variant" Uses: $ cargo --version cargo 1.41.0 (626f0f40e 2019-12-03) $ rustc --version rustc 1.41.0 (5e1a79984 2020-01-27) src/main.rs: use std::env; use std::fs::File; use std::io::{Error, ErrorKind, Read}; use std::string::String; use std::vec::Vec; type Pointer = u32; type Count = i32; type Char = u8; #[...


0

AWK + sort Just for the sake of completeness, here are two solutions that work best for different versions of AWK. This one works best with Michael Brennan's AWK (both mawk-2 and mawk 1.3.4). It outperforms GNU awk by a factor of x7.5. mawk -v RS="[^A-Za-z]+" ' { freq[tolower($0)]++; } END { for (word in freq) print(freq[word] " " word) } '...


3

Haskell, \$n=16\$ in about 9 minutes As observed by @xnor in the comments, we can break the problem down into two parts: generate polyominoes (where I reused a lot from here, then count the ways to distribute the remaining cubes. The symmetries are accounted for by using Burnside's lemma. So we need to know how many buildings of a given symmetric shape are ...


0

chevron, 6 bytes >y ->1


8

x86-64 machine code (Linux system calls), 29B * 4.7/6.6 = ~20.6 on tmpfs on Skylake Yes, this runs faster than GNU yes on tmpfs, the widely-used Linux ramdisk-like filesystem backed by the pagecache. I made sure to align my buffer to at least a cache-line boundary (and in fact a 4k page boundary) so the kernel's copy_from_user memcpy-like function using ...


1

05AB1E (legacy) / 05AB1E, 4 bytes, score: waiting for OP ['y, Or alternatively: 'y[= Try it online. Not sure which combination is the shortest, so for now this answer has four possible variations: 05AB1E (legacy) with program ['y, 05AB1E (legacy) with program 'y[= 05AB1E with program ['y, 05AB1E with program 'y[= The 05AB1E (legacy) version is ...


1

Rust, 49 bytes \$\times\,\frac{31952896}{772800512}\approx2.025\$ Plain Rust, compiled with -C target-cpu=native -C opt-level=3. Clearly not the winner, only for reference; not bad, btw :) fn main(){loop{print!("{}","y\n".repeat(8192));}} Try it online!


0

C (clang), 57 54 bytes \$\times\frac{44152832}{45940736}\approx51.8984\$ Saved 3 bytes thanks to @S.S.Anne!!! #define p putchar_unlocked main(){for(;;p(10))p('y');} Try it online! This is on my ancient tablet, probability better on my laptop that's far away right now - on holiday! :))))


1

x86-32 Linux, 26 bytes (ungolfed), 1.5M write syscall test. Produces a very underwhelming result. main: push $0x0A79 # "y\n" mov $1, %ebx # write to stdout (fd=1) mov %esp, %ecx # use chars on stack mov $2, %edx # write 2 chars loop: mov $4, %eax # sys_write call number int $0x80 jmp ...


7

Bash, 16 bytes, 16TB output, score ~0 .0018554687 Thoroughly abuses the rules trap '' TERM yes It ignores timeout's SIGTERM (running an empty command) and so continues beyond the 1 second that the benchmark script intended to set. This will fill your disk unless you kill it with a different signal or set a quota or other size limit.


1

Japt, 6 bytes No clue how the scoring in this challenge works. @Opy}a Try it online! @ :Function Opy : Print "y" } :End function a :Call repeatedly until it returns a truthy value :(Japt's O.p() method returns undefined)


3

C (gcc), 67 bytes b[1<<16];main(){for(wmemset(b,'\ny\ny',1<<16);~write(1,b,1<<18););} Your times may vary. I'm running this inside a VM on a weak computer. b[1<<16]; is an integer array of \$2^{18}\$ bytes. wmemset(b,'\ny\ny',1<<16); sets that array to a pattern of y\ny\n. The characters are reversed due to the endianness of ...


2

Python 3, 34 bytes, 1.9GB/s, score ≈ 32.711 a='y\n'*2**17 while 1:print(end=a) Try it online!


0

Python 3, 18 bytes \$\times\frac{16834568}{622668}\approx486.65\$ while 1:print('y') Try it online!


36

C, 112 bytes, 28 TB/s, score ≈ 0.008 long b[9<<21];main(){for(b[2]=write(*b=1,wmemset(b+8,'\ny\ny',1<<25),1<<27)/2;b[3]=b[2]*=2;ioctl(1,'@ ”\r',b));} (If you’re having trouble copying and pasting this, replace the multicharacter constant '@ ”\r' with '@ \x94\r' or 1075876877.) This writes 128 MiB of y\ns to stdout, and then ...


3

Perl 5 (cperl), 26 bytes while(1){print"y\n"x 9**4} Try it online! R, 18 bytes repeat{cat('y\n')} Try it online! Improved thanks to @JDL Squirrel, 24 bytes while(1){::print("y\n")} Try it online! JavaScript (Node.js), 26 bytes while(1){console.log('y')} Try it online! Python 3, 28 bytes while1:print(end='y\n'*9**4) Try it online! Julia 1.0, ...


28

Bash, 3 bytes, 1.9 GB/s yes Try it online! Admittedly this is a troll solution, but the rules do not explicitly forbid it, and it should get you a value close to 3, which is not bad.


10

C (clang), 88 63 bytes, 2.5GB/s b[2048];main(){for(wmemset(b,'\ny\ny',2048);write(1,b,8192););} Try it online! Edit: Saved 25 bytes thanks to @ceilingcat by assuming 4-byte wide characters.


Top 50 recent answers are included