Skip to main content

All Questions

3 votes
2 answers
69 views

Reading a file into lines (benchmarking getline() vs mmap_memchr() vs mmap_getline() vs fread())

This is a follow-up to: Reading a file into lines with mmap vs getline. The actual names of the functions are not ...
Harith's user avatar
  • 9,462
7 votes
1 answer
232 views

Reading a file into lines with mmap vs getline

I required a function to read a file into lines for a text editor, and ended up with two routines. One uses getline(), and the other uses ...
Harith's user avatar
  • 9,462
3 votes
1 answer
92 views

Simple C++ event loop - static vs dynamic dispatch performance

I have two extremely simple toy implementations of an event loop, and would like to understand the performance differences between them. First impl - events with a virtual 'handle' method - dynamic ...
Jnuk's user avatar
  • 33
1 vote
0 answers
129 views

Making Robert Tarjan's offline LCA algorithm run (much) faster (Java)

I have produced this GitHub repository that compares the performance of: Robert Tarjan's off-line lowest common ancestors algorithm, An improvement of the above algorithm. Typical demo program ...
coderodde's user avatar
  • 28.9k
3 votes
1 answer
80 views

calculating the percentage of distribution of ids per Loc for each country

Which of the two queries is theoretically better and why? I would like to understand why query 2 takes longer although there is no relevant information in the Execution Plan. I'm querying a Presto ...
Pin_Eipol's user avatar
2 votes
1 answer
161 views

C/C++ hash looking in flat database compared to PHP

I have a hash table which I would like to query as fast as possible. The hash table is stored this way : When I query a hash, I extract first 4 characters then use it to find the file. For instance a ...
James's user avatar
  • 41
1 vote
2 answers
114 views

Circular list vs. doubly-linked list: which is faster?

In this post, I will compare performance of a circular list and a conventional list with head/tail -references: ...
coderodde's user avatar
  • 28.9k
5 votes
2 answers
664 views

Recursively calculating powers by squaring

Consider the following function that implements optimised O(log n) exponentiation by squaring: ...
saxbophone's user avatar
2 votes
4 answers
1k views

Calculate the median value of combining two sorted lists

I have solved a leetcode problem (Median of Two Sorted Arrays), and I came up with two solutions. Solution 1 ...
111's user avatar
  • 45
2 votes
1 answer
153 views

LeetCode#494 target sum (dart is slower than python)

I'm trying to solve a LeetCode problem target-sum, in two languages: Python & Dart. The difference of time taken is shocking for me" Python took ~70ms while Dart took ~900ms !! Why does Dart ...
Abhishek Patil's user avatar
2 votes
1 answer
158 views

Card game simulations, with a multithreaded version slower than the single-threaded one

I'm new to rust and I'm trying to build a card game simulation to find all of the best actions with all possible hands. This requires a lot of simulations and my first 3 million are already taking a ...
PaulEliaz's user avatar
0 votes
1 answer
129 views

Find longest "binary gap" [closed]

I'm doing a few challenges and I found this one on Codility: A binary gap within a positive integer N is any maximal sequence of consecutive zeros that is surrounded by ones at both ends in the ...
GB5's user avatar
  • 101
0 votes
1 answer
71 views

2 ConvertToBase3 methods with great disparity of execution time

I have two methods to do the same thing: convert a number to ternary. ...
ludicrous's user avatar
  • 109
4 votes
3 answers
411 views

Pairwise Euclidean distance search algorithm

x and y are two-dimensional arrays with dimensions (AxN) and (BxN), i.e. they have the same number of columns. I need to get a matrix of Euclidean distances between each pair of rows from x and y. I ...
Никита Михалков's user avatar
1 vote
0 answers
47 views

Graph stored as adjacency list or as endpoints and intervals

I tried speeding up my Graph class, so I removed the Node class and Edge class, and decided to use arrays and ArrayLists. My 2 implementations seem very similar, ...
Will Kanga's user avatar

15 30 50 per page
1
2 3 4 5
10