Tagged Questions
Performance is a subset of Optimization: performance is the goal when you want the execution time of your program or routine to be optimal.
0
votes
0answers
12 views
Need Comments on Python SDK for Aspose Cloud [on hold]
Looking for some gurus for an expert opinion on my code.
Writing an opensource library for Aspose Cloud would appreciate if someone can review my code and give suggestion how to improve it to next ...
3
votes
0answers
21 views
Finding the longest Collatz sequence cycle
I wrote a program to calculate Collatz sequences for initial numbers between 1 and a given integer i, then find the one with the largest cycle length. My code is ...
3
votes
4answers
50 views
Improving efficiency for two sum
I am trying to solve this problem:
Given an array of integers, find two numbers such that they add up to a specific target number.
and this is my strategy:
For each ...
4
votes
2answers
57 views
Modified Sieve of Eratosthenes has very long runtime
I am slowly moving through Project Euler, and have reached problem #10:
The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
Find the sum of all the primes below two million.
I did a naive ...
1
vote
0answers
33 views
Game Engine :: Entity Component Design - Handling Input
I am currently creating a game engine for educational purposes.
ECS Design Pattern
The first design pattern I've included is the Entity/Component/System pattern. Therefore I've got a base singleton ...
0
votes
1answer
45 views
Faster way to parse file to array, compare to array in second file, write final file
I currently have an MGF file containing MS2 spectral data (QE_2706_229_sequest_high_conf.mgf). The file template is here, as well as a snippet of example:
...
4
votes
3answers
174 views
Inner product of random floats written to file
My goals are to make this code:
faster
more idiomatic C++
What the code does:
take an integer command-line argument N
make a vector of ...
1
vote
0answers
17 views
Identifying “Matching Bigrams” in Large Text Collection
I have a large number of plain text files (north of 20 GB), and I wish to find all "matching" "bigrams" between any two texts in this collection. More specifically, my workflow looks like this: for ...
1
vote
0answers
15 views
C code for hash-consing: how could its performance be increased?
I've isolated this function, cons, for hash-consing in C. It is where the bottleneck of my program is. How could its performance be improved?
...
3
votes
1answer
12 views
Bit compressing in JavaScript
I have an bit array var data = []; ... and I have the following function:
jsPerf
...
2
votes
0answers
26 views
Tick module for the game
I tried to look up and suck in most of the information about optimizing this operation and this is what I came up with. As it's pretty much core of the game, I really would like to have it performant ...
1
vote
2answers
46 views
Looking for matching names among two text files
I'm trying to enhance the execution speed of my below code. I am using only vanilla JavaScript. I would be willing to bring in additional libraries and plugins as long as they will enhance the overall ...
14
votes
2answers
309 views
11
votes
4answers
171 views
I'm not sure if I still love Fibonacci, but my code is getting better. How much better?
Technically, this is a follow up to these two questions, but I have taken a radically different approach.
Everybody Loves Fibonacci
Does everyone still love Fibonacci
I finally allowed myself to ...
-1
votes
0answers
31 views
Followup to BigInteger Cube Root Optimization
Followup to Followup: How do I optimize this Java cube root function for BigInteger?
Here's my current code for this cube root approximation for BigInteger, which returns the integer part of the cube ...
3
votes
1answer
32 views
How to generate valid number of combinations of datacenter and its host id?
I have a list of datacenters, which are dc1, dc2 and dc3. And each datacenter has six ids as ...
1
vote
1answer
33 views
improve performance of recursive function in c# method
I'm trying to write a function which will cache objects in memory.
The function below works, but performance is unbearable. What would you recommend to improve performance?
...
3
votes
2answers
76 views
+50
Increase performance on canvas repainting
I'm working on a little project where I have to create sort of an image mask.
Overall my code works quite good in all browsers but sporadically the animations "flickr" on Chrome (Windows). So I was ...
4
votes
1answer
64 views
Followup: How do I optimize this Java cube root function for BigInteger?
Followup to How do I optimize this Java cube root function for BigInteger?
So I've tried several implementations of this algorithm. The version using only BigInteger sometimes results in a ...
6
votes
2answers
178 views
Producing a sorted wordcount with Spark
I'm currently learning how to use Apache Spark. In order to do so, I implemented a simple wordcount (not really original, I know). There already exists an example on the documentation providing the ...
6
votes
1answer
36 views
Convert WKT representations of geometries into GeoJson
I am working on a class library in C# to convert WKT to GeoJson. I am getting shapes in WKT out of MSSQL. A lot of the shapes ...
4
votes
4answers
365 views
5
votes
4answers
72 views
Stack implementation using only one queue in C
We start with an empty queue. For the push operation we simply insert the value to be pushed into the queue.
The pop operation needs some manipulation. When we need to pop from the stack (simulated ...
0
votes
0answers
9 views
What's a good simple way to combat the n+1 problem? [migrated]
I'm trying to better understand performance in PHP. One issue I'm thinking about is the n+1 problem. By n+1 I mean something like this:
...
3
votes
3answers
69 views
CSV demographics analyzer seems to waste memory/move slowly
I'm much more fluent in JS, but I needed to sort a lot of dates, ages, genders, etc. from a tab-delimited text file so I wrote this. Could I get some tips on how to make this more efficient and more ...
4
votes
5answers
166 views
Search algorithm for specific values in a 3D array/matrix being super slow
I'm trying to create code that reads a text file (containing (double) numbers between 0 and 1) and filling up a 3D array/matrix (calling it matrix from now on) with ...
9
votes
3answers
353 views
How many semi magic squares are there?
I want to write a program to work out how many semi-magic squares there are.
Here is the definition of semi-magic squares
If we define \$H_n(t)\$ is the number of semi magic squares which ...
5
votes
1answer
44 views
Enhancing speed of looping cycle using Freepascal
I use Lazarus 1.2.4 and Freepascal 2.6.4.
I have created a program that reads a disk in buffers of 64Kb (tried various buffer sizes) using a repeat...until loop. Each buffer is hashed using the SHA1 ...
2
votes
0answers
49 views
Code elimination once it is conditionally dead [closed]
A situation when programming code becomes dead dynamically or conditionally, such as here in this scenario. I don't want my code to be failure victim of branch prediction.
...
-1
votes
3answers
107 views
Better sorting speed
import sys
x=int(sys.stdin.readline())
lst = [int(sys.stdin.readline()) for i in xrange(x)]
lst.sort()
print lst
How can I make this code faster for large ...
5
votes
2answers
93 views
Processing large file in Python
I have some code that calculates the "sentiment" of a Tweet.
The task starts with an AFINN file, that is a tab-separated list of around 2500 key-value pairs. I read this into a ...
6
votes
1answer
40 views
Searching for songs on an Android application
In my application I need to search for some songs on my external storage card every now and then. On startup I read everything, however when it comes to new activities I thought I could just pass the ...
4
votes
1answer
36 views
Canonicalizing a large set of addresses using many regex substitutions
I have a script that is standardizing a large amount of data in the database. The standardization involves applying over 500 regular expressions to the data.
Here is some quick pseudocode:
...
3
votes
2answers
122 views
Building a list - why is this code inefficient?
I'm attempting this code challenge.
Here's my code modified to handle one simple example test case:
...
4
votes
1answer
81 views
Parallelizing scrypt key-derivation function
To review my use of multiprocessing, I don't think it is at all necessary to understand the algorithm, but it's the scrypt key-derivation function.
This uses ...
5
votes
1answer
54 views
Spell Check and Trie implementation
I have written this code for an Edx course called CS50x (a beginner course).
This problem set required me to write a program which:
loaded a dictionary into some sort of data structure (I choose to ...
4
votes
0answers
178 views
How bad is it calling println() often than concatenating strings together and calling it once? [migrated]
I know output to the console is a costly operation. In the interest of code readability sometimes it is nice to call a function to output text twice, rather than having a long string of text as an ...
4
votes
1answer
67 views
Better way of checking if the current user already like a post
I have three models which look like this:
...
4
votes
1answer
73 views
E-commerce product price tracker
I building a very simple price tracker web app. I am using MongoDB with pymongo. The user will enter the URL of the product he wishes to track and the desired amount, when the price goes below this ...
2
votes
0answers
32 views
Slow Stan/Rstan code
I haven't found anything about Stan on Code Review, but I got great feedback with my last question here so I thought I'd give it a try.
The model takes a long time to run. I have tried to vectorise ...
0
votes
0answers
10 views
Need to use floats for performance yet want double-precision calculations [migrated]
MonoGame is an open-source version of Microsoft's XNA. It's a framework for building cross-platform games.
It has a number of mathematical types such as Vector and Quaternion.
I am a bit baffled by ...
6
votes
1answer
43 views
Rotating background using Swing: performance issues
In a jPanel, I'm displaying a 1203x1203 background that I rotate every 30ms. Problem is, Swing is known to be a slow library, and I assume rotating a huge picture at a quick rate would be quite ...
2
votes
1answer
107 views
Faster file lookup
I'm polling an ashx handler to check if a specific file is present and return true or false depending on it.
...
3
votes
2answers
57 views
performance on this substring search
I have the code below that gets hit several hundred times per second. I'm wondering what I can do to improve performance. It seems that there should be some way to build up a substring index. Is there ...
5
votes
0answers
61 views
Merging overlapping/intersecting string vectors
I am trying to merge overlapping/intersecting sets given as a list of string vectors below in R (my actual data set has thousands of such sets). The overlap/intersection is based on the ...
5
votes
3answers
121 views
Go Aaaaaaaaaaah
The problem is described in full here - Aaah!.
Input
The input consists of two lines. The first line is the “aaah”
Jon Marius is able to say that day. The second line is the “aah” the
...
10
votes
3answers
332 views
Optimize a Date and Timespan function
I have a working function that may be optimizable.
Currently processing 4 objects gives me 0.0459822 for the elapsed time in seconds - used for testing purposes. ...
1
vote
1answer
74 views
Declaring arrays knowing their maximum size
I know the maximum array size is 6. So what is the best practice to declare an array?
In the following code I used it like this:
...
1
vote
3answers
47 views
Large number to many characters
My goal is to take any size number, and convert it to a string of smaller characters that represent the concatenation of the binary expansion of the number. To illustrate what I am talking about, here ...
2
votes
1answer
69 views
Typeahead Talent Buddy
Problem is Talent Buddy.
Your task is to
write a function that prints to the standard output (stdout) for each query the user name that matches the query
if there are multiple user names ...