Questions tagged [optimization]
Optimization is the process of improving an existing program to make it work more efficiently or/and using less resources.
402
questions
1
vote
3
answers
265
views
How can single thread execution further increase since frequency stagnates?
What are things that newer CPU can do to speed up single thread execution?
multiple registers? (can compilers always benefit from it?)
SIMD? (do compilers use SIMD without code annotation?)
does a ...
0
votes
0
answers
47
views
Production Line Optimization in MATLAB
I'm trying to model a metal treatment process to improve its efficiency. We have 11 different components that all have to flow through the same process, but each component spends a different amount of ...
0
votes
4
answers
186
views
Should a null block be used for semantic purposes?
I was writing a procedure that is only applicable in a particular case, but it didn't feel right to enforce it by contract or raising exceptions, because there's no problem with calling it in other ...
0
votes
0
answers
74
views
Is it possible to build a semantically unambigous grammar / language / graph?
It's been a long time that I had an idea of a semantic constraint as compiler optimizations which allows for sophisticated high level optimization allowing you to transform the AST/CFG based on a SFG (...
0
votes
3
answers
128
views
Optimize reservation system algorithm
Im am developing a logistics application and at the moment, I try to solve the following problem:
In the system, there are multiple machines.
Each machine has one or more skills. For example, machine ...
-2
votes
2
answers
270
views
How does Java and other managed languages achieve any performance, if everything is allocated at random places of the heap? [closed]
Prelude
Recently, I helped a friend of mine in coding him a problem for his university Algorithms course, where problems are submitted in Java. I sent him code with good O notation complexity, ...
0
votes
0
answers
42
views
Designing an optimization on throughput of EF.Core application
I am looking for feedback on a design problem I encountered when processing batches of db entries. The issue at hand is efficiency and throughput of an application.
The application looks like this ...
0
votes
1
answer
141
views
How can I minimize the number of captured variables in lambda expressions? [closed]
If a lambda is frequently used, it is considered to reuse the same instance instead of creating new instances repeatedly.
How can I minimize the number of captured variables in lambda expressions?
15
votes
4
answers
5k
views
Better solutions than joining table for Many to Many?
Lets say I have students and classes which are 2 entities. A student can take many classes and a class can have many students. This would be a many to many relationship.
To solve this with an RDBMS my ...
24
votes
10
answers
9k
views
Shouldn't deep copy be the default, not shallow copy?
If you have an OO language, where every object always has a copy method, shouldn't that be deep copy by default?
In most languages I know, such a copy method is shallow, since a shallow copy is more ...
0
votes
1
answer
321
views
How do function inlining and Tail Call Optimization affect call stack?
I've just accidentally came across this answer about inlined functions and I'd like to know how this affects call stack. But I can't add comments because I don't have enough rep so I decided to ask ...
3
votes
1
answer
406
views
Simulated Annealing
In relation to another question I had, I have been researching Simulated Annealing.
The general example used with this algorithm is the traveling salesman example. I have been testing the code ...
2
votes
2
answers
256
views
Optimizing Flash Memory Writes in Embedded Systems with Unpredictable Power Loss
I'm working on an embedded C++ project that involves logging certain types of statistical data (like successful accesses, failed attempts, and other events) to the flash memory (just incrementing ...
0
votes
1
answer
141
views
Use PGO (profile guided optimization) to determine optimal value of variables in code
Reading this interesting paper it seems that a lot of performance loss is due to scheduling overhead in tight loops. To recap: There's a variable called "Chunksize" which determines how big ...
8
votes
3
answers
229
views
Choosing one of two memory blocks to deallocate: Does age affect fragmentation?
First question here, so preemptive apologies if I've committed some faux-pas. Additionally, I am aware that this question is about possibly the micro-est of micro-optimizations ever, and "micro-...
1
vote
2
answers
340
views
String representation in Python runtimes
Python is one of the few languages to support a string data type of code points (Unicode Scalar Values). I'm also wanting to creating a language that has this same characteristic, but I need to ...
5
votes
4
answers
2k
views
Is it better to iterate over data once and do multiple complex operations, or to iterate multiple times with simpler operations?
Here I'm working in Python, but it's more of a language agnostic question, unless specific language features makes it clear that an option is better than the other.
I get my raw data from a REST API, ...
-1
votes
1
answer
119
views
Is it practical to cache multiple instances of variable API data (updates hourly for each instance) for N users?
I'm using flask with SQLAlchemy on a postgresql database for a mobile app I'm building. My application allows a single user to save lets say up to 5 different locations which are saved in the database....
0
votes
1
answer
174
views
Is it premature optimisation to test a condition to skip a small loop?
I have an array of entities which have an id property:
entities: {id: string|null}[] = [];
All items in the array are guaranteed to have id !== null and the array will not exceed 100 items.
Now I may ...
0
votes
3
answers
2k
views
Optimizing a string to enum converter [closed]
I have built a string to enum converter, which converts a known set of strings that it receives into enum, in order to satisfy a function pointer. Some of you may recognize some elements of this ...
0
votes
1
answer
459
views
How to optimize average rating calculation in a review system?
I'm thinking of a designing a review system (restaurant, hotel etc) where users can drop star reviews. Typically in a such a application, you can see the average rating of an entity along with all ...
-1
votes
1
answer
105
views
How to measure the impact of a website speed optimization
Given:
You have a list of opportunities* that may improve the speed metrics of your website. For example Total Blocking Time (TBT) is one metric that heavily impacts the experience of a visitor.
You'...
0
votes
3
answers
3k
views
Optimal method of storing image thumbnails
I'm working on an application with a database containing many recipes. The API is written in Django (with Django REST Framework) and frontend in React.Each recipe is assigned a high-quality image. In ...
-1
votes
2
answers
233
views
Performance hit after non-functional refactoring
I was asked to refactor some C++ code recently for the purposes of increasing unit testing coverage. The problem was that the code was tightly coupled on one compilation unit, so we had the equivalent ...
0
votes
0
answers
38
views
Feasibility of Delievery App
In my town, recently a delivery company has been opened (think DoorDash but on a much smaller scale and only doing local deliveries).
Now what really confuses me is that they charge pennies for each ...
0
votes
0
answers
44
views
Optimizing database lookup with No SQL MongoDB
My restraints are that I have to use:
Django and MongoDB
I am trying to build a website that will read some JSON input and then parse all the properties and objects in the JSON and display results. ...
0
votes
1
answer
2k
views
Java: Is there a performance difference between variable assignment vs. inline usage?
Is there any performance detriment to assigning variables vs using them inline. I'm guessing this WOULD be worse if a method was returning primitive and I was 'boxing' it (e.g. method returning int, ...
0
votes
1
answer
169
views
In C and C++, can a compiler store an unamed object generated from a expression, if that same expression is reused, but the result is unchanged? [closed]
I'm mostly interested in C and C++, but I think this question can also apply to other languages.
My question is, if an unamed object or value is generated from the evaluation of an expression or ...
1
vote
1
answer
2k
views
How to remove unused code from a jar file? [closed]
I have a jar file, for example foo.jar. My code contains a lot of libraries (almost 75 jar dependencies). I am not using anything like maven or gradle, I'm just using pure java with pure jar files as ...
0
votes
1
answer
166
views
Worried about too many joins when fetching multiple datatypes in a single postgres query
Its not exactly my use case (would take too long too explain), but imagine a task management application where tasks for employees are displayed in a list along with some information about that task. ...
-3
votes
1
answer
91
views
Choosing between network optimisation and CPU usage in clientside web development [closed]
I'm working on a CSS library that includes hundreds of selectors and rules for quick templating instead of writing regular CSS.
This is used as a replacement of attr() CSS function until it works for ...
-1
votes
1
answer
955
views
How to optimize the request time for large data response?
I have created a dashboard for rendering a list of clients into a DataTable. Below shown is the data model structure:
When I had a few records in the clients schema, let's say a thousand rows, the ...
-2
votes
1
answer
333
views
Recommended way of caching weather information
I'm developing an application that will show some weather information based on the user's location. Since the weather forecast is just a very small feature of the app that complements the main ones, I ...
-4
votes
1
answer
68
views
Calculate math function depend on N value [closed]
I have method with the following prototype :
R[] = method(k,n)
which :
n = ordinal value 0 <n <10^9
k = math function depend on n value : i.e n^6
R = array of computed values
For example :
n = ...
-1
votes
1
answer
77
views
In a language interpreted line by line - is optimizing similar lines of code within a module into functions better in terms of efficiency? [duplicate]
While writing python code (I write python-selenium for GUI automation), I am facing situations wheer I have to deal with 5 widgets that do the same thing, just there xpath is differs by one term.
# ...
-3
votes
1
answer
198
views
Techniques I can use to optimise my C++ code further? [closed]
I'm working on loading PNG files. I know there are existing libraries, but I'm doing this for learning purposes. Previously, I was using LodePNG, which is a great library that performs really well.
I ...
-1
votes
1
answer
38
views
how to model this relation by linear constraints?
v = |x1-x2| with 0<=xj<=C for j=1,2, C constant
I was trying to moel this relation by linear constraints. This is what I've done
equality is equivalente to superior and inferior relation.
...
2
votes
0
answers
141
views
Branch Prediction: How does a correlative branch predictor select from the global history?
I am trying to understand how branch prediction works, specifically with regards to correlative branch prediction. I understand that in an (m, n) branch predictor, there are m branch predictors, with ...
1
vote
4
answers
291
views
Software-design for algorithm engineering
I'm currently working on an program that solves a graph optimization problem.
I know the "standard" software-design principles like information hiding, modularization, etc. What I'm ...
-1
votes
1
answer
186
views
What kind of bin packing problem is this?
I have a problem formulation but it does not resemble the usual packing problem I find in the literature but it is a usual problem in the packing industry. I just do not know the name for it.
The ...
0
votes
2
answers
213
views
Drawing all lines from right to left - fast
I have several drawings from SVG files which basically contain basic outlines of figures. They are constructed in segments of various shapes (lines, ellipse arcs, Bezier curves ect.) Something like ...
26
votes
4
answers
6k
views
Do compilers optimise in concurrency?
Presuming that I have written some sequential code where it can be broken down into multiple isolated tasks, it seems it might be efficient for concurrency to be introduced.
For example
print(...
-2
votes
1
answer
462
views
How to manually delete a std::vector in c++? [closed]
I have following code snippet
void func(int row,int n,std::vector<int>& buffer){
if(row>n){
return;
}
std::vector<int> new_buffer;
for(int elm : buffer){
...
4
votes
2
answers
135
views
Separation of data retrieval and processing in loops?
Often I need to get some data and process it in some way. For example getting a list of customers from an API and assemble some summary data on them. As an example, getting :
api_result = api.request(...
2
votes
1
answer
198
views
How to play sounds optimally in the browser?
I have a new site that allows you to play sounds of letters on click. Each letter produces a separate sound. I went from roughly 500kb for .wav files to around 30kb for each sound file. That's a lot ...
0
votes
1
answer
147
views
Need help with React Shape building app architecture
I am trying to figure out how to build most scalable and maintainable architecture for my app.
The app is just about choosing some shape and then editing it.
More precisely, choosing some existing ...
2
votes
3
answers
1k
views
Are lessons on tail recursion transferable to languages that don't optimize for it?
I'm currently reading through Structure and Interpretation of Computer Programs (SICP). During the course of that book, the lesson of "you can optimize recursive procedures by writing them as ...
-2
votes
3
answers
184
views
Code optimization tool [closed]
Would it be possible to develop a program that could optimize algorithms, detect design patterns and then rewrite the code? For example:
Detect a Bubble sort and transform it into a Quick sort or a ...
0
votes
3
answers
194
views
Does the assembler perform the same tasks as the translator from C to assembly?
When compiling C programs to assembly programs and then to machine programs, does the assembler (e.g. the one used in GCC or other popular C compilers) perform the same tasks as the translator from C ...
-3
votes
2
answers
122
views
Default assignment before if-elseIf or within if-elseIf-else , What is better in terms of performace/optimzation? [duplicate]
I have a piece of code where I need to assign a value to a variable, but base on condition, it could take other values. It can be done in multiple ways, but need to know which would be preferred in ...