Skip to main content
OverflowAI is here! AI power for your Stack Overflow for Teams knowledge community. Learn more

Questions tagged [optimization]

Optimization is the process of improving an existing program to make it work more efficiently or/and using less resources.

Filter by
Sorted by
Tagged with
0 votes
4 answers
181 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 ...
Devsman's user avatar
  • 601
0 votes
0 answers
70 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 (...
C5H8NNaO4's user avatar
  • 129
0 votes
3 answers
101 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 ...
pschill's user avatar
  • 1,860
-2 votes
2 answers
262 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, ...
blonded04's user avatar
  • 105
0 votes
0 answers
40 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 ...
Samuel's user avatar
  • 723
0 votes
1 answer
136 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?
Arunabh Bhattacharya's user avatar
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 ...
Jeremy Fisher's user avatar
23 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 ...
Mecki's user avatar
  • 2,330
0 votes
1 answer
233 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 ...
b3rry's user avatar
  • 3
3 votes
1 answer
324 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 ...
wforl's user avatar
  • 159
2 votes
2 answers
218 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 ...
Dario.Casciato's user avatar
0 votes
1 answer
129 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 ...
glades's user avatar
  • 419
8 votes
3 answers
224 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-...
Da Spud Lord's user avatar
1 vote
2 answers
274 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 ...
Hydroper's user avatar
  • 121
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, ...
L'Animal Fou's user avatar
-1 votes
1 answer
87 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....
joepaji's user avatar
0 votes
1 answer
169 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 ...
lampshade's user avatar
  • 103
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 ...
HFOrangefish's user avatar
0 votes
1 answer
415 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 ...
Ahmed Sadman Muhib's user avatar
-1 votes
1 answer
102 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'...
Jeremy Gottfried's user avatar
0 votes
3 answers
2k 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 ...
gandalf113's user avatar
-1 votes
2 answers
214 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 ...
Component 10's user avatar
0 votes
0 answers
37 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 ...
Freshman's Dream's user avatar
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. ...
xf900's user avatar
  • 1
0 votes
1 answer
1k 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, ...
nanotek's user avatar
  • 301
0 votes
1 answer
168 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 ...
SingleQuestion's user avatar
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 ...
Day Trip's user avatar
0 votes
1 answer
137 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. ...
user2741831's user avatar
-3 votes
1 answer
90 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 ...
Tot's user avatar
  • 147
-1 votes
1 answer
627 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 ...
Saud's user avatar
  • 109
-2 votes
1 answer
303 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 ...
Cornwell's user avatar
  • 117
-4 votes
1 answer
67 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 = ...
whiteRice's user avatar
-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. # ...
Ulysses's user avatar
  • 101
-3 votes
1 answer
181 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 ...
NeomerArcana's user avatar
-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. ...
Ayman's user avatar
  • 1
2 votes
0 answers
132 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 ...
Adam Lee's user avatar
  • 129
1 vote
4 answers
285 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 ...
Moritz Groß's user avatar
-1 votes
1 answer
184 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 ...
David Zanger's user avatar
0 votes
2 answers
195 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 ...
DrDress's user avatar
  • 127
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(...
Ben's user avatar
  • 369
-2 votes
1 answer
425 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){ ...
ShayakSarkar's user avatar
4 votes
2 answers
133 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(...
User's user avatar
  • 1,551
2 votes
1 answer
181 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 ...
Lance's user avatar
  • 2,611
0 votes
1 answer
139 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 ...
Nick's user avatar
  • 111
2 votes
3 answers
967 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 ...
J. Mini's user avatar
  • 1,007
-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 ...
Axeryon's user avatar
0 votes
3 answers
193 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 ...
Tim's user avatar
  • 5,465
-3 votes
2 answers
100 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 ...
Sachin Gupta's user avatar
-3 votes
1 answer
1k views

Is it good practice to call service layer through domain object getters?

Tell me anybody, is it good practice to call service layer methods through domain object getters? Let me show you with an example: public class User { private long id; private String name; ...
Artem's user avatar
  • 3
-2 votes
1 answer
235 views

Should graphql api implementation select specific fields from database before resolving?

I recently had to optimize my graphql API server by selecting only specific fields from the database before returning the actual result to the client. For example, let's say my graphql schema has the ...
Yos's user avatar
  • 157

1
2 3 4 5
8