Questions tagged [performance]

Performance is a subset of Optimization: performance is the goal when you want the execution time of your program or routine to be optimal.

Filter by
Sorted by
Tagged with
12
votes
2answers
4k views

More efficient way to retrieve data from JSON

I am using the jsmn JSON parser (source code) to get extract data from a JSON string. jsmn stores the data in tokens that just point to the token boundaries in the JSON string instead of copying the ...
12
votes
7answers
9k views

Sieve of Eratosthenes

For practice, I've implemented Sieve of Eratosthenes in Java by thinking about this visual animation. I would like to hear some suggestions for improvements, especially how to make it more efficient ...
11
votes
2answers
319 views

Segmented wheel Sieve of Eratosthenes in Python

Here is a new version of a segmented and wheel factorized Sieve of Eratosthenes. It currently uses mod 30 wheel factorization to eliminate multiples of 2, 3, and 5 in the sieve data structure to gain ...
10
votes
1answer
1k views

Recording audio in C 2.0

I posted my audio recording program to Code Review before, and received a stern review along with the other reviews that caused me to rewrite the entire code base. Here is what I would like reviewed: ...
8
votes
2answers
106 views

Hand Coded State Driven Lexical Analyzer in C With Unit Test Part A

This code review is presented in 3 questions due to the amount of code: Part A (this question) contains the Lexical Analyzer and the main portion of the unit test code. Part B contains the lower ...
8
votes
1answer
763 views

Java application for finding permutations efficiently

I am an eighth grader with a school project of creating and application in Java that returns the total permutations of two given numbers. It needs to be light and efficient, for later deployment on a ...
7
votes
3answers
3k views

Fast alternative for String.split by whitespace

After profiling of one project I've found a bottleneck in the code, specifically the line: String columns[] = line.split("\\s+"); I've tried to find a workaround,...
7
votes
1answer
362 views

Brainfuck Interpreter: Slower than a Snail?

Inspired by FizzBuzz by Brainfuck, I decided to write an interpreter for Brainfuck. It: Removes all non-command characters Optimizes commands (removing +- and <...
6
votes
2answers
1k views

Lock for preventing concurrent access in client data

I am trying to implement lock by which I don't want to have reads from happening whenever I am doing a write. Here is my ClientData class in which I am using ...
6
votes
3answers
2k views

Optimizing unique partitions of integers

I am working on a project involving the unique partitioning of integers. I.e. I am looking to have all of the partitions of n = x1 + x2 + x3 + ... + xk, where xi = xj implies i = j. For example, if I ...
5
votes
2answers
432 views

Modern, C++ compliant, merge sort

This is a kind of follow up to my previous sort implementation review with specific questions to merge sort, and Modern C++ idioms. ...
5
votes
2answers
704 views

Prime Number calculation bottleneck

Inspired by another question here: Sum of Prime numbers under 2 million, I decided to try and implement Eratosthenes' Sieve from scratch using the algorithm described in the article. ...
5
votes
2answers
253 views

A Matrix Library in C++;

I have written a Matrix library that contains all the main properties of matrices. It's a relatively long project, I am hoping it is ok to post here since I really want to have it reviewed. The ...
5
votes
2answers
1k views

Prime Number Speed

I know prime number programs have been beaten to death. I have been programming for eight years (not that long, but I'm not in my 20s yet and I got a programming job straight out of high school so I'm ...
3
votes
0answers
90 views

Writing Go object code that respects Go guidelines

I'm learning Go and I wrote this for a programming challenge. It is working (building and running) but I feel the code is not what Go code should be: Am I using the ...
3
votes
4answers
1k views

Poker Hand Evaluator

Poker is 52 cards - 4 suite and 13 rank: Hand is exaclty 5 cards Order of hands Straight-flush - all same suite and in order Quad four of same rank Boat three of one rank and two of another rank ...
3
votes
1answer
162 views

Stable reversed Tartaglia's triangles

Inspired by Minimising the triangle I am writing a fully tested program to solve the following problem: A triangle needs a good foundation. Every row in the triangle is derived from the sum of the ...
3
votes
1answer
2k views

Project RoboNest - Basic Nestable Robot Framework For Loop

Purpose: To allow nested For Loops with a minimum of syntax change from the standard For Loop. Reason: I want to nest For Loops in Robot Framework. The code is working perfectly as a custom library/...
1
vote
2answers
685 views

Project Euler #3 solution

I'm trying to solve Project Euler problem #3, which asks: The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? Can you please review the ...
10
votes
5answers
4k views

Efficient FizzBuzz

I wrote the following Fizz Buzz program. How can I improve it or make it more efficient? ...
10
votes
1answer
215 views

Optimize CoffeeScript comparison function

I've wrote this CoffeScript function to compare values in a table, but it turned out to be a HUGE function. Since the code is really really long, you can find it here as well. Code explanation: The ...
7
votes
3answers
360 views

Having full atomicity against all the threads without impacting performance or throughputs

I am working on a project in which I construct a URL with a valid hostname (but not a blocked hostname) and then execute that URL using RestTemplate from my main ...
6
votes
2answers
138 views

Scan a directory for files and load it in memory efficiently

I am working on a little project where I need to scan all the files present in a folder on the disk and load it in memory. Below is my code which does that exactly and works fine. Here are the steps: ...
6
votes
2answers
122 views

IntModulus reloaded

As my question Modular arithmetic was hard to review and terribly long, I've added a few comments to the easier part, namely IntModulus. The code uses Guava and ...
6
votes
2answers
754 views

Typeahead autocomplete functionality challenge

I'm working on a Talent Buddy challenge . In this challenge you have to design the autocomplete functionality of Twitter. You are given a list of queries and possible usernames. You have to return the ...
5
votes
1answer
70 views

Hand Coded State Driven Lexical Analyzer in C With Unit Test Part C

This review is presented in 3 questions due to the amount of code: Part A contains the Lexical Analyzer and the main portion of the unit test code. Part B contains the lower level unit tests called ...
5
votes
2answers
199 views

Validator refactored to be OO

Based on my previous post I completely re-factored my code to make it object oriented. Anything I could improve when it comes to: Object oriented code; Efficiency; Readability. Any other ...
4
votes
1answer
39 views

Hand Coded State Driven Lexical Analyzer in C With Unit Test Part B

This review is presented in 3 questions due to the amount of code: Part A contains the Lexical Analyzer and the main portion of the unit test code. Part B (this question) contains the lower level ...
4
votes
2answers
5k views

Codewars: Sum of Pairs

I've been working on this task (see screenshot). Here's my answer to it so far: ...
3
votes
2answers
271 views

BigRational based on BigIntegers

For Project Euler I've implemented a BigRational. The functionality is rather limited, just things I needed or will probably need soon. The style departs a bit from ...
3
votes
1answer
11k views

Filtering a list based on conditions

I'm currently filtering a list based on several conditions, which may or may not be present: ...
3
votes
1answer
75 views

Testing for divisibility of numbers - follow-up

(Here is the follow up question) I had another go at trying to speed up my program described in my previous question. JS1's answer was particulary helpful and now my code is only about 20% slower ...
3
votes
1answer
192 views

VBA syntax that compiles sub data into master sheet

I am using this syntax to bring in the names of all employees whom are active, then from there filter the data on subsequent worksheets and use a formula to bring the data over to the ...
2
votes
1answer
482 views

3D bin packing in Java

I made some changes to the first code here I wrote and I want to know which one is more correct logically (before the changes or after the changes). It's really hard to manually test these kind of ...
2
votes
2answers
750 views

Project Euler problem 23 - non-abundant sums

I present my solution for Project Euler problem 23 written in Python (2.7). The problem statement is: A perfect number is a number for which the sum of its proper divisors is exactly equal to ...
2
votes
2answers
109 views

Program to test for divisibility of numbers

(EDIT: here is the follow up qusetion) Using this program to test for the smallest number where its permutations or itself is divisible by 10 or less numbers is twice as slow as the fastest program I ...
2
votes
1answer
1k views

Extract data from large JSON and find frequency of contiguous sub lists

I have been writing some code (see component parts here and here) that: Takes a very large JSON (15GB gzipped, ~10million records) Extracts the relevant parts of the JSON into a list of lists Creates ...
2
votes
1answer
77 views

Optimize program to test for divisibility of numbers 3.0

This is a follow up on my previous question. JS1's answer suggested that I should use a precomputed table containing all permutations of the lowest valid number for each number between 1 and MAX. It ...
1
vote
1answer
572 views

Fast Prime Sieve (Python Implementation)

A modified version of the prime sieve. I actually doubt it could be implemented any faster, but I might be wrong: ...
1
vote
1answer
104 views

Project Euler 34 # Digit Factorials in Python

145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145. Find the sum of all numbers which are equal to the sum of the factorial of their digits. Note: as 1! = 1 and 2! = 2 are not sums they are ...
1
vote
2answers
93 views

Neatly printing integers interspersed with spaces - follow-up

See the previous iteration. At this point, I have "digit group" length assumed to be always 3 the user can pass the delimiter character of his/her own handles (seems to handle) the minus sign ...
1
vote
1answer
128 views

Looping through with varied subtotal ranges

I've got an issue where my looping through the rows on my sheet are extremely slow. For 20,000 rows, it takes about 20 minutes, whereas before, it was taking 3. The only pieces I added were at the ...
0
votes
1answer
158 views

Three function Calculator 2.0

A week ago I did a three function calculator, I took the input from you guys and made it better. Overall it works fine, I didn't find any problems. But as a beginning programer I'd like some input on ...
0
votes
1answer
592 views

Class for finding the median of a two-dimensional space

I have a simple static class that it's purpose is given an RDD of Point to find the median of each dimension and return that as a new ...
-1
votes
1answer
149 views

Optimize finding GCD of all pairs of divisors

I've come up with a solution for Euler Problem 530, but my code runs too slowly to actually get the answer (solving for 10^15). What can I do to optimize it to run faster? ...
193
votes
5answers
32k views

Dijkstra path finding in C# is 15x slower than C++ version

I'm implementing Dijkstra's algorithm with a priority queue for a game I'm developing in Unity with C#. I was a bit disappointed with the performance, so I decided to port the code to C++ and see if ...
31
votes
10answers
15k views

Sorting large 1GB file with 100 millions numbers using merge sort

My task is to sort 1GB file with 100 million numbers using merge sort without recursion. My idea is to split file into 4 pieces, then to 2 and at the end to one file. ...
44
votes
2answers
96k views

Finding the closest point to a list of points

I'm trying to find the closest point (Euclidean distance) from a user-inputted point to a list of 50,000 points that I have. Note that the list of points changes all the time. and the closest distance ...
-47
votes
2answers
2k views

Derpifying Images

Just wondering if there was someone out there that could offer help in optimizing my script which "derpifies" images. ...
27
votes
5answers
6k views

High performance txt file parsing

EDIT2: There is a summary below of the findings with new improved code and run time results achieved. Multi threaded follow up has been posted here. I find, in my daily programming, that text-file ...

1
2
3 4 5
12