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.
2
votes
0answers
13 views
Mandelbrot fractal with MPI
I'm not very familiar with MPI. I've written this little piece of code to draw the Mandelbrot fractal processing each row of the image in parallel. It works but it's really slow. I've written code to ...
3
votes
1answer
22 views
Shell script to count chess game outcomes
I came across this blog post by Adam Drake from around a year ago which is now making the rounds again.
I made some improvements to his code, but wish to see if there are additional tweaks that could ...
10
votes
2answers
297 views
Reverse a sentence quickly without pointers
I am trying to reverse a sentence contained in a string and return a string in the quickest way possible using the least amount of memory. Also I don't want to use any unsafe code, so no pointers are ...
2
votes
2answers
70 views
Find Missing Numbers in an int list
I have an alternative algorithm to the same problem as Finding missing items in an int list.
My implementation includes optional min and max bounds to selectively fill in the list.
The linked ...
1
vote
1answer
67 views
What could I possibly change with this BFS and code to enhance its performance?
This code is supposed to find, in a graph, the node with the smallest maximum distance to all the other nodes. The problem can be found here.
For instance, in this example graph:
2 is the node ...
4
votes
1answer
39 views
Performance optimization on Box2D with libgdx
A few days ago I decided that I wanted to get involved with libgdx. So far I'm blown away by how simple it is to get something on the screen to work with.
I'm trying to make a very simple tech demo ...
1
vote
0answers
64 views
Quick estimation for empirical permutation and correlation test in R
I have two matrices (a, b), each including 3 genes and 6 observations. I have estimated the Spearman correlation for gene pairs (rcorr.observed). Then I want to do an empirical permutation (1000 ...
5
votes
1answer
67 views
Speeding up Python date conversion function currently using list comprehension and datetime
I am reading a large data file where the time is given in number of days since some epoch. I am currently converting this to Python's datetime format using this function:
...
1
vote
1answer
25 views
Dynamically calculate status in MLM
Problem: dynamically calculate status in MLM only based on a structure.
It works correctly but it's so slow. Only test processing takes about 20 seconds. I tried to replace some lists by generators, ...
4
votes
1answer
34 views
Vectorization for temperature simulation
I'm new at Matlab and I would like to know tips in order to reduce the processing time of such program. The scheme of the actual code is very similar to typical C++ code and i would like to vectorize ...
3
votes
1answer
46 views
Detecting which properties have been changed from two objects
I have the following code. Providing two objects cmd and this.xxx.properties, script detects the only property changed and ...
2
votes
1answer
54 views
Accessing list elements when counting the number of rectilinear paths
I am trying to solve the RIVALS problem on SPOJ: Starting from (0, 0), how many paths are there to reach point (X, Y), only taking one-unit steps moving to the right or up? Constraints: 0 ≤ X ≤ 106, ...
8
votes
1answer
129 views
+50
Individuals reproduce and mutate
How can I improve the performance (in terms of computation time) of this code?
...
2
votes
1answer
28 views
Reading a dynamic record length binary file
I am trying to read a dynamic record length binary file, which has data like this:
field1field2field3field4vector1vector2
Here, field3 defines the occurrence of ...
5
votes
3answers
105 views
Counting letters as quickly as possible
I received a task, of taking a known text file (Linux dictionary), use threads to count the different letters in it, and present the results in an array.
The code doesn't have to be pretty, elegant, ...
1
vote
1answer
63 views
Faster solution for row-wise matrix subtraction
I have 2 matrices. I have to calculate the euclidean distance between every row of matrix A and every row of matrix B.
In the first solution I loop over the rows of the two matrices and for each row ...
2
votes
4answers
141 views
Java vs C++ (JAVAC)
Here's the problem for Java vs C++ (JAVAC):
Java and C++ use different naming conventions.
In Java a multiword identifier is constructed in the following manner:
The first word is written ...
4
votes
1answer
76 views
Finding the minimum number of required deletions to have a non-repeating string
I wrote code for the following problem:
Given a string, print out the number of deletions required so that the adjacent alphabets are distinct.
Please suggest different methods by which I can ...
5
votes
2answers
129 views
Speed optimization for block XOR
In code I'm currently maintaining, there is a need to do very many repeated XOR operations of blocks of memory. The block size in my case is always 16 bytes. Because the code is executed very ...
2
votes
1answer
109 views
Loading 40GB twitter JSON TAR file from archive.org and load into PostgreSQL
I wrote the script below to load data obtained from the twitter JSON archive on archive.org into a PostgreSQL database.
I'm looking for optimizations in the code. It currently runs at ~1.7 seconds ...
1
vote
4answers
102 views
Project Euler #1 - JavaScript
I'm new to JavaScript, and decided to learn the language by running through as many of the Project Euler problems as I have time to do. I just finished the first one, and am looking for some feedback, ...
4
votes
2answers
50 views
Faster way to perform function calculation in Python?
I'm interested in whether there is a way to further improve a "fast" version of a function used in a homework assignment I received recently (I've already submitted the completed work).
...
2
votes
0answers
53 views
Golang concurrent HTTP request
I wanted to test the performance of concurrent http request in Go against node.js:
...
2
votes
1answer
67 views
Javascript Performance Optimization
I am using the code below that loops around thousands of time, I need this to be as fast as possible, however I am not an expert in Javascript and all I know is that this code is faster than doing it ...
8
votes
1answer
74 views
Minesweeper analyze goes to N-Queensland
As @rolfl recently solved the N-Queens problem, I figured that it was time also for me to solve it.
My approach is significantly different from @rolfl's. I quickly realized that the N-Queens problem ...
2
votes
1answer
32 views
SQL query to order by the difference between FIRST and BEST scores
Can anyone help me optimise this query? I have the following table:
...
0
votes
0answers
52 views
Recursive partition sort is inefficient
I have written a recursive method for a partition sort that sorts the array. However, when I use an array of more than 10-20 elements the program takes a really long time to complete. (On my computer ...
4
votes
1answer
41 views
C++11 class similar to .Net's ManualResetEvent, but without the ability to “reset”
The goal is to block all threads that call WaitOne(). When Set() is called, those threads continue. Any calls to ...
3
votes
2answers
145 views
Brute force algorithm for printing all possible alphanumeric combinations
I'm still very much a beginner, so I don't really know much about best practices or the speed of any particular C functions.
You'll notice that I included a "cs50" library. This is from a MOOC I'm ...
4
votes
1answer
42 views
Flying-balls on a canvas element
I have made this little program for fun, to add on my personal webpage. I remember seeing something like it some time ago, don't remember exactly where, and I tried to reproduce it myself.
As it ...
4
votes
1answer
65 views
Finding a password with brute force
The purpose of this code is to find a password with brute force cracking where as it will try all the possible combinations until it finds the correct password. For example, it will start like a then ...
2
votes
1answer
74 views
Very slow graph walking
My code is very very slow. Could you give me hints on how I can make it much faster?
...
1
vote
2answers
59 views
Speeding up Hexadoku
I have serious problem with my Hexadoku (16 x 16 , a - p) solver. I'd like to run the program in under 2 seconds but my solution solves it in 10 seconds.
Native Code:
...
1
vote
2answers
50 views
Sort and display input numbers
How do I decrease time, especially in sorting?
Given a list of numbers, you are to sort them in non-decreasing order.
Input
t – the number of numbers ...
4
votes
2answers
211 views
Checking for duplicate materials
This is a follow up question of Importing different type of files into Lists. Where the original lists are acquired.
In this script I am processing the obtained lists, and comparing them with each ...
3
votes
1answer
42 views
Sieve of Eratosthenes in Scheme (R7RS)
I've seen many implementations of Sieve of Eratosthenes in Scheme, but I thought I'd try to write one that is both space- and time-efficient:
Space-efficient: I use R7RS bytevectors as a bitset, ...
6
votes
3answers
313 views
Optimizing an Anagram Solver
I've built an anagram solver in Python 2.7. It goes through a text file with over 100,000 words and checks if any permutations of the input matches the line. It works great, except it is very slow. ...
0
votes
0answers
8 views
Why is the C# Task Parallel Library code slower than a normal for loop? [migrated]
I'm wondering why the parallel code isn't faster than a normal for loop with this code:
...
3
votes
2answers
86 views
Print all permutations with some constraints
I've the following problem:
Print all valid phone numbers of length n subject to following
constraints:
1.If a number contains a 4, it should start with 4
2.No two consecutive ...
4
votes
3answers
320 views
Project Euler Problem 12 - triangle number with 500 divisors
I've just done Problem 12 of Project Euler:
What is the value of the first triangle number to have over five hundred divisors?
The \$N\$'th triangle number is the sum of all natural numbers ...
3
votes
0answers
75 views
Switching between view controllers that are loaded in the background
I have a dining menu app that scrapes the data from a website and redisplays it in a mobile format, displayed below:
If the user swipes left and right, the app will show the previous/next meal (ex. ...
5
votes
2answers
49 views
Computing the RPY tensor with C++/Eigen (linear algebra)
I'm mostly used to writing scientific code in MATLAB / Python / Julia and my experience with C++ is very limited. I've implemented a fairly simple computation of the Rotne-Prager-Yamakawa tensor in ...
1
vote
0answers
38 views
AI for an online contest
I'm actually creating an AI for the online contest Vindinium. The fact is that's also an exam for my school because I'm going to have a note with that work.
I created an AI based on ants pheromones ...
8
votes
3answers
197 views
Speed up Sudoku Solver
I made this Sudoku solver using depth first search, it takes less than 0.1 second to solve any simple solution(no guessing), but if the solution requires guessing (thus using the DFS) its time grows ...
6
votes
1answer
95 views
4
votes
2answers
71 views
Retrieving stock prices
It takes around 5-8 seconds for me to retrieve a previously-closed stock price and a dividend rate from US Yahoo! Finance. If I wanted to retrieve 10+ stock prices, it would take me more than a minute ...
2
votes
1answer
46 views
HTML Compressor with regex
I would like to compress a Magento HTML page using some regex, and this is what I have written:
...
2
votes
2answers
81 views
Divide certain distinct row values into separate columns
This might be difficult for me to describe clearly but I will try anyway. Also note that this is entirely speculative; it might not even be able to run any faster (that is why I am asking).
This is ...
3
votes
1answer
46 views
Slow Javascript code to get Taxonomy terms from Sharepoint
We have the following code which takes about 5 seconds in a modern computer, however the application is also executed on old PCs with Windows XP, and in there it takes 5 minutes to load. I know the ...
1
vote
3answers
72 views
Looping to update article codes on one server based on queries on another server
I've read somewhere on Stack Overflow that doing queries in a loop is very inefficient. It will hammer your SQL server and make your script very slow.
Sample code:
...