Performance is a subset of Optimization: performance is the goal when you want the execution time of your program or routine to be optimal.
1
vote
1answer
23 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 ...
4
votes
1answer
61 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 ...
1
vote
0answers
22 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
3answers
66 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
45 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
21 views
Golang concurrent HTTP request
I wanted to test the performance of concurrent http request in Go against node.js:
...
2
votes
1answer
54 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
64 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
22 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
47 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
33 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
132 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
37 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
0answers
49 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 ...
1
vote
1answer
64 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
55 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
45 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
203 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 ...
2
votes
1answer
38 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
303 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
7 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
84 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
313 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
69 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
47 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 ...
2
votes
0answers
34 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
195 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
90 views
4
votes
2answers
62 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
43 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
75 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
38 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 ...
0
votes
3answers
65 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:
...
2
votes
0answers
28 views
HLSL Shader Model 4: Is there a way to avoid pixel shader computing all code paths?
I have a pixel shader that needs to output either a plain colored pixel or a texel sampled from one of three textures - selected by a switch statement operating on an index fed in by the vertex ...
5
votes
1answer
37 views
Slow query joining orders and products
The end result I am trying to achieve is an array containing the total ordered qty for each product. I have been successful but the query takes about 20 minutes to run and I'm wondering if there is ...
-5
votes
1answer
34 views
Java Improving code efficiently [closed]
ve used the following function in one of my programs.
I have tried to make sure that my code is efficient however I cannot find any help online to tell me how to recognize where I could improve...
...
8
votes
2answers
82 views
Making Multiple Copies of a Pattern
Here's a function for making multiple copies of a block of memory in another block of memory. It handles the case when the size of the target is smaller than or not a perfect multiple of the source ...
6
votes
2answers
53 views
Modular arithmetic brute-force congruence finder
My full code is running too slow. I do profile.run to my project and found out this function consumes a lot of time.
The main problem is just to return an array containing all \$x\$ satisfying both ...
12
votes
1answer
57 views
Parallelization of number factors using OpenMP
For a simple try at parallelization on my own outside of school, I've created a number factors calculator. I hope to eventually come up with something more creative.
Since I don't have access to ...
5
votes
2answers
876 views
How can I find out why this Rust program to echo lines from stdin is slow?
Given the following Rust program:
...
3
votes
0answers
45 views
Scraping efficiently with mechanize and bs4
I have written some code that scrapes data on asteroids, but the problem is that is super slow! I understand that it has a lot to scrape, but as of now it has been running for 5 days and is bot even a ...
2
votes
1answer
44 views
Process zip files
I have zip bundle, for example, abcd.zip, contains more zips like 1.zip, 2.zip etc. Inside of each child zip there is a .jpg file like 1.jpg, 2.jpg etc. There are so many other files but I need only ...
2
votes
0answers
30 views
Speeding up loop-rich Matlab function to calculate temperature distribution
I would like to speed up this function as much as possible in Matlab.
This is part of a bigger simulation project, and as it is one of the most called functions within the simulation, this is crucial.
...
3
votes
2answers
55 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 ...
2
votes
1answer
28 views
Write to a new, modified Excel file from an original one
I noticed that I've a HUGE bottleneck in this following function of mine. I can't see how to make it faster.
These are the profiling test results(keep in mind that I'm using a PyQt GUI so times can ...
3
votes
2answers
70 views
Speed up loop through JSON
I have the following function that takes JSON and turns it into table rows:
...
3
votes
1answer
57 views
Parsing Lua 5.2 strings with patterns
I wrote some code to parse Lua 5.2 strings in Lua 5.1, using patterns. It's a bit too slow, but it works fine as far as I tested.
...
9
votes
1answer
232 views
Multiplication 128 x 64 bits
I was fooling around with the Collatz sequence a bit and found out that long is only sufficient for starting values below ...
7
votes
3answers
83 views
Removing equivalent authors in a list
I have a list of authors, where seeking duplicity. The indexes of these duplicates are stored in a list of lists named duplicity. For example, at index 0 in the list duplicity is nested list, which ...
3
votes
1answer
37 views
Loading and displaying JSON quickly in PhoneGap app
I have this tap event in an iOS app that I'm developing with PhoneGap. When I click on the left arrow, it finds the desired content and retrieves it from a JSON file. It then displays those results on ...