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
8 views
Segmented Sieve Optimization
I implemented this for the Prime Generator problem on SPOJ, but I am only getting 0.01s run-time, and would like to be able to match the run-times of the top submissions, which are all 0.00s.
What ...
-4
votes
0answers
24 views
What is the best/Optimal way to refactor multiple for loop? [on hold]
Here is my code which is going to through multiple for loops to get the matching product attribute.
I have single product with attributes trying to find out the ...
0
votes
0answers
15 views
Batch file - Calling same label multiple times [on hold]
I've written a batch script but there are lots of call that should be removed. Does anyone have some ideas about simplifying my script?
...
7
votes
2answers
48 views
Short and Messy Polybius Square
I attempted to recreate the Polybius square, also called the Polybius checkerboard, which was used in Ancient Greece for cryptography. Since it is an uncommon cipher, it is nowhere on Code Review.
...
1
vote
1answer
37 views
Hackerrank Gemstones Solution
I'm looking for any possible improvements in terms of memory usage and speed, but really any advice is welcome.
Problem statement:
John has discovered various rocks. Each rock is composed of ...
4
votes
0answers
53 views
Super calculator in C
For my mathematical research, I am to deal with very large numbers and I know that the standard C types are not going to stand a chance against them due to their limited capacity, so I decided to ...
4
votes
2answers
234 views
CodeWars: Gap in Primes
I wrote a javascript code for finding the first two consecutive prime numbers (that doesn't have divisors except one and itself) with a specific gap between them. It works well but take too much time ...
0
votes
0answers
30 views
find all number in a string use sscanf
I want to find out whole number in a string, which started and end by { and }, and use , to ...
-3
votes
0answers
19 views
Consolidating event listeners, or being unnecessarily redundant? [on hold]
In my project, I'm at a point where I need to attach a handful of event listeners to various HTML elements (buttons). A few, in particular, share a parent element, which makes me want to use a ...
3
votes
2answers
44 views
Calculate XOR of many consecutive and non-consecutive numbers
question:
answer(start,length)
#start is the starting number of the matrix
#length is number of rows.
example 1:
answer(0,3)
...
5
votes
2answers
115 views
Find K biggest numbers in the array
I was trying to implement method number 2, from this article.
Method 2 (Use temporary array) K largest elements from arr[0..n-1]
Store the first k elements in a temporary array temp[0..k-1]....
2
votes
2answers
59 views
Finding the coordinates on an edge of a square
I wrote a calculation that finds coordinates on an edge of a square, but it came out as a really long nested tangle of conditions. After some reduction and finding common pieces I arrived at this ...
1
vote
1answer
44 views
Incrementing colors
I just started messing around with Java's BufferedImage. I had an idea to try to encode a message into a picture by coloring each pixel a certain color that ...
3
votes
2answers
52 views
Validation Extension method performance
I'm writing a simple set/framework of extension methods for argument/parameter validation. What I'm mostly concerned about, ATM is the performance, against the simpliest boilerplate
...
3
votes
0answers
77 views
Selecting kids for a Christmas play with similar heights
I am doing this problem on SPOJ. The challenge is :
My kid's kindergarten class is putting up a Christmas play. (I hope he gets the lead role.) The kids are all excited, but the teacher has a ...
6
votes
2answers
56 views
Printing mutual anagrams
Question:
An anagram is a word that can be written as a permutation of the
characters of another word, like "dirty room" and "dormitory"(ignore
spaces). However, "the" and "thee" are not ...
6
votes
4answers
239 views
Balanced Parentheses checker in Python
I'd appreciate feedback on the code itself (style, performance optimization (both space and time)), and also on the algorithm (because I think this is typically implemented using a stack).
The ...
2
votes
2answers
244 views
Processing lots of JSON objects
I want to process a ton of JSON objects as quickly as possible.
I've done my best to make the processing as concise and efficient as I can.
How can I make it more efficient?
...
2
votes
2answers
68 views
Search through each file in a directory, list number of instances of searched string
I am trying to open each file listed in Sheet2 Column A, search for a string of text located in Sheet3 Cell B1, list the number of instances this string appears in each particular file in Sheet3, and ...
4
votes
1answer
40 views
Merging rows in excel using VBA
For the first time I've worked in Excel VBA to find rows in my dataset that contain the same adress as another entry in a cluster. These entries have to be merged and the row then is deleted. I've ...
-4
votes
0answers
30 views
OpenMP : parallel implementation of independent loops [on hold]
The below code snippet was optimized using OpenMP, as the three functions were taking independent arguments and there were no loop dependencies in three loops I tried to use "omp parallel" along with ...
5
votes
3answers
1k views
Combining .txt files
A guy at the company I work for needed a small application that would combine multiple text files into one, larger text file.
I wrote a console application for this. it seems pretty efficient, but I ...
3
votes
2answers
47 views
Custom UUID based on time
I've been using random UUIDs—from Rust, e.g. Uuid::new_v4()—for my primary keys in a MySQL database. I recently happened across this, which suggests ...
2
votes
1answer
58 views
Scrapy Username Spider
This currently starts out with the speed of 2000 pages/min but shortly after starting it becomes very slow with a speed of about 200 pages/min. Why is this happening? How can I improve this scraper?
<...
3
votes
2answers
40 views
Pairwise distance and residual calculation
I have a code for calculating the pairwise distances and the residuals of my data (X, Y, Z). Data is quite large (average of 7000 rows) and so my interest is code efficiency. My initial code is
...
2
votes
1answer
59 views
Flattening a nested map [on hold]
We're migrating our streaming ETL application from Python into Clojure,
the hottest part of the code isn't yet performing as well as our existing
implementation. This looks to be down to the ...
1
vote
0answers
15 views
SICP - exercise 2.5 - Represent pairs of nonnegative integers
Exercise 2.5. Show that we can represent pairs of nonnegative
integers using only numbers and arithmetic operations if we represent
the pair a and ...
3
votes
1answer
80 views
KMP algorithm searching from the right
The generic version of extension method is aimed to work like String.LastIndexOf which can search t from the last position of <...
0
votes
1answer
41 views
Displaying weather data from an Arduino
Please review my code, for performance and readability.
3 issues I am facing are
Uncaught Exception : out of memory (in firefox)
randomly Failed to load resource: The request timed out.
Even if the ...
7
votes
1answer
108 views
A Moses's worthy string splitter
I am trying to perfect my string splitter's performance, to be more fast, more easy to maintain if someone else reads it and more readable code-wise.
Context ,Scope and Objectives
Where I work we ...
7
votes
0answers
78 views
Vectorizing the product of an array of complex numbers
I am trying to write fast/optimal code to vectorize the product of an array of complex numbers. In simple C this would be:
...
0
votes
1answer
37 views
Fire Scheduling with Triggers in CMMS
I worked on cmms project .
I have some scheduling , esch of schedule have some triggers (e.g,. Bymeter , byActivity ,ByPeriod).
I wrote some methods to generate workOrder for each Schedule if ...
135
votes
4answers
20k 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 ...
1
vote
1answer
67 views
Split string into “n” lengths with padding
I quickly wrote a short program to split a string into \$n\$ lengths with variable-character padding:
...
3
votes
1answer
65 views
Measuring the length of binary numbers in English words in C
Inspired by this question (link to original video), I decided to write some code in C to perform this task, and it is much faster than the Python code, even when run with PyPY, up to a billion, it ...
2
votes
1answer
69 views
Storing and accessing 3D struct array efficiently
I have a structure, and have come up with 3 different 3D arrays to store it in. The thing is, optimization is not my specialty and I need advice from someone who knows their stuff regarding best ways ...
2
votes
2answers
47 views
Crank-Nicolson. Advection - Diffusion. Perfomance
I am writing an advection-diffusion solver in Python. I am quite experienced in MATLAB and, therefore, the code implementation looks very close to possible implementation in MATLAB. I implemented the ...
4
votes
1answer
54 views
Simple Affine cipher
The affine cipher is a simple mathematical substitution cipher. If you're interested in the details behind how it works, this page goes further into detail.
After writing a program to encrypt and ...
5
votes
5answers
147 views
Simply print the string backwards
This code is very, very simple, but I was wondering how it could be improved:
...
7
votes
2answers
92 views
Neural Networks in C
This block of code is one of my first C header files I have made; it's ported from a Python program I made a few months ago for a project.
I was just looking for advice on how to increase the ...
10
votes
4answers
742 views
Random string of variable length generator
Below is my code for generating a random string of random length. I am using it in integration tests. Currently I have almost 2000 tests running each time a commit is made to master and a few of those ...
3
votes
1answer
53 views
Batch convert txt files to xls
In this SO question I provided two answers for the batch conversion of more than 100K txt to xlsx files
I suspect any automation of Excel is too slow, but would appreciate if there is a superior (i....
2
votes
1answer
43 views
HashCash Algorithm header generation in Haskell
A thought exercise on my part as I'm relatively new to Haskell. I wanted an interesting project to work on so I decided to implement the Hashcash Algorithm, which is most commonly used as the basis of ...
0
votes
3answers
41 views
Vanilla JS mouse events on dynamically created elements
In terms of performance, what is the best way to bind mouseover/mouseout event on dynamically created elements?
This is what I have but I'm not sure it is ok for performance:
...
2
votes
0answers
45 views
Brick Pop puzzle solver in Rust [closed]
I'm making a puzzle solver for the Facebook game "Brick Pop" (a little game you can play on a Messenger with friends and I made that solver for fun). It works but it's sooo slow! I can't even solve ...
0
votes
1answer
63 views
A quartic polynomial in four variables, for numerical integration
About half year ago, I derived a integral of a piecewise polynomial, which was a complex formula. Below is one of that formula:
Obviously, the above formula has relationship with four varibles \$u_i,\...
1
vote
1answer
40 views
Codewars Challenge Kata
I was recently doing a challenge on Codewars and this is what challenge said:
There are no explanations. You have to create the code that gives the
following results:
...
0
votes
0answers
40 views
Open and read a large number of files from folder [duplicate]
Is this the fastest way to open a large number of files and read their contents? (The folder may contain lakhs of files.)
...
2
votes
1answer
133 views
Calculate stock portfolio profit based on CSV data
import time
import csv
import argparse
from nsetools import Nse
from colorama import Fore
nse = Nse()
t = time.time()
CSV file contains the following data, I ...
3
votes
2answers
56 views
Implementation of Trie Structure
I want to improve this code. I know I'm not fully utilizing the data structure. (This is not a homework assignment, I finished and passed the class this fall semester). I would really like to know for ...