Questions tagged [processing-efficiency]
622 questions
3
votes
2 answers
Does the product of two constants get computed every time it is executed?
For example, if I have:
if(x < 2*0.025) { ... }
Does the 2*0.025 get computed every time? Or does a 0.05 get substituted in so that the multiplication operation doesn't have to run every time?
In other words, is it more efficient to use 0.05 instead…

Ryan
- 5,883
- 13
- 56
- 93
3
votes
1 answer
What is the most efficient file modification method? Adding many lines to the same file, or reading in, processing, and writing out the file?
I have a perl script that must create a file, write a few hundred lines of content to it, then read all the lines it's written and add lines whenever it finds a match based on a separate configuration file. It's not as ideal as just writing all the…

Andrew Makin
- 55
- 6
3
votes
1 answer
Curious case of efficiency of equation algorithm, why are more operations faster?
I lately wrote a bit that shall smooth out the extends of a 0-1 range. Out of curiousity I measured the performance of two possibilities to acchieve the same end result. What came out is that this:
_ = (Mathf.Sin(-1.57079633f + (time * 3.14159265f))…

CBX_MG
- 93
- 8
3
votes
2 answers
Why are sequential regular expressions more efficient than a combined experession?
In answering a Splunk question on SO, the following sample text was given:
msg: abc.asia - [2021-08-23T00:27:08.152+0000] "GET…

warren
- 32,620
- 21
- 85
- 124
3
votes
0 answers
Is it better to increase process niceness or limit number of cores used on a shared system?
I've often worked in settings where several users have access to the same machine for computationally intensive tasks. The machines in question are standard linux machines (no docker/kubernetes or similar).
In some cases, there has been a policy to…

bjarkemoensted
- 2,557
- 3
- 24
- 37
3
votes
5 answers
c# fixed arrays - which structure is fastest to read from?
I have some large arrays of 2D data elements. A and B aren't equally sized dimensions.
A) is between 5 and 20
B) is between 1000 and 100000
The initialization time is no problem as its only going to be lookup tables for realtime application, so…

BerggreenDK
- 4,915
- 9
- 39
- 61
3
votes
1 answer
Merging overlapping images into a single image by correctly positioning the patches one on the other
Given many patches that are taken from an image, the task is creating a single image that is composed of the patches.
I have tried the naive solution:
for every 2 images, go over many patches and compare.
If they are similar above some confidence…

GalSuchetzky
- 785
- 5
- 21
3
votes
2 answers
find intersection of 2 doubly linked lists
I have an assignment where I need to find the intersections of 2 singly-linked (singly vs singly) lists. I also have to do it for 2 doubly linked (doubly vs doubly) lists:
For singly linked list, I use mergeSort() to sort both lists and then…

lalaland
- 379
- 3
- 15
3
votes
6 answers
Find which element of list is a key in a dictionary and what is it's value
I have a dictionary:
classes_dictionary = {'/m/09x0r': 'Speech', '/m/03qc9zr': 'Screaming'}
and a list:
labels_list = ['/m/03k3r', '/m/04rlf', '/m/07q5rw0', '/m/09x0r', '/m/0jbk']
labels_list will always contain at least one element which is a key…

havakok
- 1,185
- 2
- 13
- 45
3
votes
2 answers
Most efficient way to calculate frequency of pairs of numbers in a 2D Numpy array
Let's say I have the following 2D array:
import numpy as np
np.random.seed(123)
a = np.random.randint(1, 6, size=(5, 3))
which produces:
In [371]: a
Out[371]:
array([[3, 5, 3],
[2, 4, 3],
[4, 2, 2],
[1, 2, 2],
[1, 1,…

MaxU - stand with Ukraine
- 205,989
- 36
- 386
- 419
3
votes
1 answer
How to read input line by line in Racket efficiently?
I currently use the following method of reading a file line by line:
(for [(line (in-lines))]
However, right now my code is too slow. Is there a "faster" way to read the input line by line?

Wallace
- 107
- 4
3
votes
2 answers
Efficient keys for dictionaries
I'm new to posting here, so I hope I provide enough detail. I'm trying to find out if key selection effects the efficiency of dictionaries in Python. Some comparisons I'm thinking of are:
numbers vs strings (e.g. would my_dict[20] be faster than…

ThatNewGuy
- 197
- 11
3
votes
2 answers
What is the most efficient way to determine if a point is in any number of boxes
I know how to check if a X,Y point is a single rectangular region, but say I have multiple regions that can potentially overlap ( the regions would have X,Y,Width,Height,Z-index ( or x1,y1,x2,y2 if that's easier -- I am not fussed on how I store…

Dre
- 4,298
- 30
- 39
3
votes
3 answers
Most efficient way to search enumerable
I am writing a small program that takes in a .csv file as input with about 45k rows. I am trying to compare the contents of this file with the contents of a table on a database (SQL Server through dynamics CRM using Xrm.Sdk if it makes a…

Ben
- 2,518
- 4
- 18
- 31
3
votes
1 answer
JS Object of Arrays vs JS Array of Objects efficient and performance
This question regarding javascript language.
Simply think we have a map and we insert item as following manner
var dataMap=new Map();
//First Mechanism
//firstly we can think of structure of values of map can be JSONArray of objects
…
user6952310