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
26 views
How can I optimize this curl script? (PHP) [on hold]
When I run var_dump($title), I get results really quick, but my script fetchs the whole page in order to get one result, then do it again, again. How can I do this ...
3
votes
2answers
33 views
Rapid color replacement for in-memory BMP
A function that relatively quick replaces one color with another, in a memory-buffered BMP.
I am trying to improve the performance as much as it is possible. The previous implementation of this ...
2
votes
2answers
42 views
Sieve of Eratosthenes JavaScript implementation - performance very slow over a certain number
I've been playing around with the code challenges on projecteuler.net. A few of them involve prime numbers, so I've created a function to find them based on the sieve of Eratosthenes.
It works fine, ...
4
votes
0answers
46 views
malloc(), free(), realloc() using brk() and sbrk()
I recoded malloc() by using brk() and sbrk(). I just want some "reviews" to see if it is ...
4
votes
0answers
38 views
Xonix game in JavaScript
This is my very first program in JavaScript. I am trying to teach myself from JavaScript: The Definitive Guide, 6th Edition.
The code is also available on my bitbucket.
I decided to remake the ...
0
votes
0answers
8 views
Implementation of Logistic Regression
Is this kind of vectorized operations the most efficient way to do this in matlab? Any critics about my code? Am I doing something wrong (i tested several times, I think it works). Notice that I use J ...
3
votes
1answer
81 views
5
votes
0answers
44 views
+100
Optimizing performance of slow complicated article-sorting query
In short I have a bunch of articles (~100k) which shall be ranked ("mixed", hence "newsmix") based on their newsValue (how important they are, between 1 and 10) and newsLifetime (how long they stay ...
5
votes
1answer
40 views
TCP Server using NIO to save data from IoT clients
I've built a small single threaded TCP server using NIO.
This server is used by small client devices to report things like temperature, when the device has been switched on, when it switches off, and ...
2
votes
3answers
46 views
Thread safety and performance when multiple threads write into same Writer
Multiple threads write data to a file. When maxLines is reached, the file is closed and a new file is created:
...
2
votes
1answer
28 views
Project Euler #10 in Cython
I'm trying to teach myself some Cython. To do so, I use Project Euler #10:
The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
2 Find the sum of all the primes below two million.
My Cython ...
4
votes
3answers
249 views
Optimizing this Knight's Tour
My assignment in CS was to make a knight's tour application that could solve the problem from any starting position. I had just finished the code so excuse the lack of deeply descriptive comments. My ...
15
votes
3answers
1k views
Duplicate like a weapon, arrays like heaven
Challenge:
Find the duplicated entry.
Specifications:
Your program should accept as its first argument a path to a filename.
Each line in this file is one test case.
Each line ...
3
votes
4answers
147 views
Count the ways to partition an array into two equal sets
I need to count the number of ways to partition an array into two contiguous arrays such that those arrays contain exactly same set of items.
Suppose ...
2
votes
1answer
37 views
Efficiency and correctness of my randomized selection algorithm
Instead of picking a random pivot I'm shuffling the array beforehand. Does it count as randomization and is it efficient to shuffle or pick a random pivot and is my implementation pythonic?
Problem
...
1
vote
3answers
21 views
Word/expression list frequency distribution
I have another Python issue, creating a frequency distribution out of a text matching a predefined wordlist. In fact, I work with more than 100,000 text files (each consisting of about 15,000 words), ...
0
votes
3answers
57 views
Check whether a date is a valid future date
I'm looking to increase the conciseness of this code. I realize that I can use Joda (or Java 8's new date API), but if I were to keep this to just Java 7, any suggestions? (I care less about ...
3
votes
1answer
29 views
Iterate over large list of lists and replace its elements
I have a large list of lists, where each list contains words/characters as elements, and each list is of different length and may contain same words/characters more than once, as for example:
...
4
votes
1answer
71 views
Optimizing code to find maximum XOR in Java
This problem is from HackerRank (not a competition, just for practice)
Basically what you do is take in two integers as a range and then finding the maximum XOR from a pair of integers in that ...
3
votes
1answer
53 views
Find the smallest number of square numbers to create n
An interview question I got -
Given int n, find the smallest number of square numbers that fit inside n.
Example:
...
3
votes
0answers
35 views
How can I speed up the reading and writing of pixels of BufferedImages?
I'm working on a project that takes in a video file and does some image processing on each individual frame. The first step in that processing is to take each source frame and generate three ...
2
votes
2answers
42 views
Premium palindromic primes
Challenge: Write a program which determines the largest prime palindrome less than 1000.
The answer is 929, and my program correctly finds and prints this, but actually ended up being more complex ...
3
votes
1answer
24 views
Return most recent non null field values for multiple unknown fields
I am attempting to create a stored procedure that looks at one table and imports changes in that table to another.
This stored procedure is going to be preformed on multiple source tables and will ...
4
votes
5answers
106 views
Optimising single-delimiter string tokenisation
I am trying to optimise my tokenizing of tab delimited strings:
...
2
votes
1answer
39 views
Improving time complexity of cheapest travel route algorithm
Below is the code to find the cheapest route for a passenger. stationsUnexplored is a Queue to which stations are added and ...
0
votes
1answer
73 views
Need fast csv parser for Python to parse 80GB csv file [closed]
I am looking for the fastest way to parse an 80GB csv file with 300 columns in Python.
The csv file does not have backquote commas, e.g a,"blah,blah,blah",c
I ...
6
votes
1answer
134 views
4
votes
0answers
29 views
Resource-constrained project scheduling
I'm trying to implement an algorithm for a resource-constrained project scheduling problem. I have several resources, resource constraints and all of this is in ...
1
vote
1answer
20 views
Counting how many LCD segments are needed to display a number [closed]
I made a program which reads digits of series of numbers and then tells you which would need the largest number of "lines" to be written with a classic digital calculator (example: for 1 you need two ...
3
votes
1answer
27 views
Integrate the product of four infinite series functions
I wrote the following code to integrate the product of four functions.
Two of the functions are hypergeometric functions and the other two are incomplete gamma functions. I have written each function ...
1
vote
1answer
26 views
Updating height of the rows in tables with jQuery
Does it make any sense and how to modify the JavaScript/jQuery code below to increase the performance? The working code is:
...
8
votes
1answer
119 views
The finest integers are palindromes
Challenge:
Reverse the digits of a number and add it to the original
until the number is a palindrome
Specifications:
Your program should accept as its first argument a path to a filename.
...
5
votes
2answers
58 views
Tile rendering/position updating performance
The code below grabs the contents of a .txt file, and scans each character of it, using that data to create a tile set. My main concern, is that for each loop, I am opening and closing a file each ...
2
votes
1answer
43 views
Optimizing search by id in some data in JSON structure
I have an object created by a JSON data. I need to retrieve the id for an object, I would like to know if a faster way exist, considering I am using for ..in loop.
...
0
votes
0answers
22 views
Optimize CSS Rule Dumper
I have written the following Tampermonkey/Greasemonkey script. I am trying to obtain a list of all CSS rules for a page; across all stylesheets. As of now, I am just iterating over everything. Is ...
2
votes
0answers
35 views
Creating chat box with comet
I'm writing chat application. I would like to know if there are problems in this code.
This function sends message:
...
6
votes
1answer
100 views
An algorithm that finds the number of “lined up columns”
I found this question in an old exam in computer science. I solved it in a good way, but I'm not convinced that my solution is the best solution. I believe that there's a better way to solve it.
...
1
vote
4answers
70 views
Coupon collector
This is a coupon collector code to analyze the running time. I need some suggestions on improving the running times of this code. I have used the data structure dictionary, but is there any other data ...
1
vote
1answer
33 views
Get friend lists
I've never written on VKScript (and on Javascript). I need high performance code to get more friend lists faster.
...
4
votes
1answer
39 views
Showing items and categories after clicking on a subcategory
How can I speed up my app? It's very slow if I click on a button and open a new page. All data in time is local. I'm not sure if the problem is in my code or xamarinu.
...
3
votes
2answers
169 views
Hacker Rank - Lonely Integer
This is the problem statement for Lonely Integer.
There are N integers in an array A. All but one integer occur in pairs. Your task is to find out the number that occurs only once.
Input Format
...
6
votes
1answer
95 views
HackerRank - Insertion Sort - Part 2
This is the problem statement for Insertion Sort - Part 2.
In Insertion Sort Part 1, you sorted one element into an array. Using the same approach repeatedly, can you sort an entire unsorted array?
...
8
votes
2answers
64 views
Encoding and decoding small strings of text
This is supposed to encode and decode small strings of text. Unfortunately, even on a really good laptop, it performs slowly. This might have to do with my looping, or just the sheer computation.
It ...
4
votes
1answer
290 views
Powershell search millions of files as fast as possible
I once asked a similar question but in C#. Now I have the same problem in powershell..
What is the fastest way, to search files newer than 15 minutes, in a file system with more than 1 million files?
...
4
votes
0answers
48 views
Finding cycles in a graph that pass through a vertex at most k times
I have a project that relies on finding all cycles in a graph that pass through a vertex at most k times. Naturally, I'm sticking with the case of k=1 for the sake of development right now. I've come ...
5
votes
3answers
142 views
Optimize huge text file search
I have several huge 100MB text files that I need to scan through to pick out certain frame numbers which relate to a specific log packet of interest. My plan was to scan for these frame numbers and ...
4
votes
7answers
2k views
Project Euler #10 — Summation of primes takes forever
I have resolved the Problem presented in Project Euler #10:
The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
Find the sum of all the primes below two million.
But this code takes too ...
5
votes
0answers
139 views
Database abstraction layer for PHP web application
I'm working on a PHP based web application.
While building the UserStorage class, (which acts as a storage source for user data, and implements the ...
5
votes
2answers
67 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
2answers
60 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 ...