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
15 votes
4 answers
4k 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
22 votes
10 answers
8k 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,290
0 votes
1 answer
165 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
247 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
166 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
109 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
  • 351
8 votes
3 answers
218 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
222 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
853 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
67 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
166 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
322 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 ...
Sadman Muhib Samyo's user avatar
-1 votes
1 answer
101 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
1k 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
194 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
167 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
103 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
87 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
412 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
286 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
65 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
76 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
161 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
37 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
115 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
266 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
180 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
183 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
372 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
121 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,541
2 votes
1 answer
157 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,585
0 votes
1 answer
127 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
838 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
183 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
189 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,425
-3 votes
2 answers
85 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
204 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
  • 155
0 votes
1 answer
254 views

Microservices Conditional API Call Design

I always think about this scenario where we need to perform a task conditionally and the task requires calling another microservice. What I am not able to understand is which microservice's ...
rohanagarwal's user avatar
7 votes
5 answers
8k views

Is using 64 bit integers (long long) faster than less bits ones?

I read in the book "Game Engine Architecture" by Jason Gregory that: "It’s possible to access data items that are narrower than the width of a machine’s data bus, but it’s typically more costly than ...
user avatar
-3 votes
2 answers
44 views

Passing different sized parameters cost savings

I was wondering if there is some cost saving, either in time or space by passing and/or returning smaller arguments? char vs int. I have heard the compiler will optimize the code based on the type of ...
Christopher J. Holland's user avatar
1 vote
1 answer
61 views

How could I optimize an AJAX-based site by avoiding unnecessary/duplicate file-reads for each AJAX call?

I'm an IT guy (read: not a professional programmer) and have made an internal monitoring webtool which allows users to search for printers on our print servers. Based on the filtering criteria given, ...
mmseng's user avatar
  • 121
0 votes
1 answer
89 views

Transitive matching in streaming application

Problem A streaming application should perform matching transitively i.e. if A == B & B == C then A == C Current Implementation Application accepts domain objects in a streaming fashion and ...
Bond - Java Bond's user avatar
3 votes
2 answers
247 views

Does removing unused features from libraries through compiler flags increase or reduce security risks?

Software libraries targetting resource constrained environments like embedded systems use conditional compilation to allow consumers to shave space and thus increase performance by removing unused ...
TZubiri's user avatar
  • 435

1
2 3 4 5
8