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
-6
votes
1answer
92 views

Is it reasonable to expect someone to solve the “Optimal Coin Problem” in 30 munutes if they've never seen it before? [closed]

I am referring to this problem: https://en.wikipedia.org/wiki/Change-making_problem I got this problem as part of a technical assessment for a job. I implemented the greedy algorithm instead of the ...
6
votes
7answers
505 views

Relevance of optimization techniques

I've heard of some techniques to optimize code and make it faster: On one side are clearly relevant optimization: use of better algorithms, benchmarking, etc. On the other side are techniques with a ...
2
votes
4answers
220 views

Iterating through objects with slightly different interfaces

I am constructing modular logic for my object: separate pieces of functionality are going to separate modules. I will have the ability to connect and disconnect modules on demand. At some point my ...
4
votes
0answers
118 views

What is 'hand native' optimization?

In the seminal 1989 Microsoft memo Zero-defects code by Chris Mason (which is still a great read even today), the term 'hand native' is used several times. Some examples: 1. Users measure our ...
-2
votes
1answer
80 views

How to profile a program for performance without a profiler?

This is a general question but with a specific use case. There is only a single and completely unaffordable profiler for the Xamarin framework. So this makes me wonder if there are some programming ...
3
votes
5answers
517 views

Is there a way to speed up a big switch statement?

As a practice I'm working on a CPU simulator (runs at about 1.78MHz) and I'm using a switch statement to execute correct opcodes based on the value in the IR (instruction register) variable. This ...
0
votes
0answers
27 views

The optimal way to simulate vision detection from limited visual field

I need to build an experiment based on a scientific paper in which a high number of agents have a divided visual field (with limited detection distance) and have to detect other agents in a 2D ...
0
votes
1answer
57 views

Fuse 3D-Points in Bundle Adjustment?

I'm actually implementing my own Pose-Estimation/- and -Refinement pipeline. For this purpose I use one moving mono-camera. Then I take the consecutive images to estimate the pose and triangulate the ...
0
votes
2answers
116 views

Improve website speed with better user session management

I have an ecommerce website wherein as soon as a new user comes on website then a new visitorId gets generated for that user in database and that visitorId cookie gets stored in his browser and in ...
-1
votes
1answer
231 views

Do C# compilers optimize away the facade pattern?

In C#, if I hide away implementation behind a facade, or the "pimpl" pattern, does the compiler optimize away the intermediate function call if all it's doing is calling an equivalent method from ...
0
votes
0answers
54 views

Storing KPI metrics in database table instead of caching all the time?

I have an application that has different types of data and KPI's that a customer could query, currently I only provide a simple and basic thing that is calculated each time a web request comes ...
1
vote
2answers
216 views

Minimizing code duplication without using macros or sacrificing speed

Here's a snippet of code: An inlined function: inline void rayStep(const glm::vec3 &ray, float &rayLength, const glm::vec3 &distanceFactor, glm::ivec3 &currentVoxelCoordinates, const ...
2
votes
2answers
231 views

Memory optimization of public methods in java

Does it optimize a program in java to declare methods private wherever they can be private or it doesn't change a thing and it's just a question of encapsulation? I was asking myself if declaring a ...
8
votes
1answer
440 views

How can I optimize a program's performance when no profiling tools are available?

I am currently working on an OpenGl program whose performance I would like to improve. The performance is okay but not ideal on powerful dedicated GPUs, but is abysmal on integrated graphics (< 10 ...
2
votes
0answers
106 views

Implementing an iterator vs. looping over a list

I want to loop over a number of rows in a database and I have implemented an object in order to access the rows. Now when using this object I am not sure about the best practice. Implementing an ...
-2
votes
1answer
116 views

Sphere parameter optimization: how would I approach it? [closed]

I am looking to construct a program that takes, as input, 576 [x, y, z] points as well as 576 corresponding distance values. I want to find the [x, y, z, radius] parameters of a sphere such that the ...
2
votes
1answer
150 views

How can I optimize an alert system that processes 1000 requests / hour?

I am building a solution where IoT-devices send in measurement-data to an API that's hosted on AWS. For each measurement-type the user can set a threshold value; that when reached will trigger an ...
-1
votes
1answer
201 views

Wait and wake-up vs. start and join for multithreading

A function that is repeatedly called should do multiple tasks: request a vector from a server. calculate a new vector. send this latter to a server. append the new vector summed to the downloaded one ...
1
vote
2answers
317 views

Avoid if-else block in favor of default assignment followed by if

A colleague, and frankly better software engineer that me, is telling me that this pattern let variable = someDefaultVariable(); if (some_boolean) { variable = someOtherValue(); } is better than ...
0
votes
1answer
111 views

Provide iterator while generating power set [closed]

I have written a code in C# to generate the power set of a given input list of integers. public List<List<int>> GeneratePowerSet(List<int> Set) { int setCount = Set.Count; ...
2
votes
3answers
296 views

What's faster.. Multiple variables or single array? [duplicate]

I have a C-coded function that realizes a very long calculation on a microcontroller. I try to optimize it for speed at the moment. The function content is created automatically using Mathematica. It ...
0
votes
0answers
70 views

Results of testing different compiler optimizations of GNU GCC are confusing

I tested out a few different compiler optimizations on GNU GCC, in the CodeBlocks IDE. With each different optimization I ran the same test: I let my program try to build as big of a tree as it could ...
2
votes
2answers
108 views

How to profile before optimising for readability

When optimising for speed, profiling first can help focus the effort on the parts of the code that bring most benefit. Since speed can be measured objectively, the benefit can also be measured ...
4
votes
3answers
477 views

How to optimize a mixed stack/register bytecode with control flow and side effects?

I'm trying to figure out a technique to optimize bytecode for the following virtual machine: Bytecode is a flat list of instructions, with execution starting from the first instruction. Stack ...
0
votes
2answers
82 views

Problem in modelling this because too slow calculation (robot football)

I like to build a component connector view / UML diagram for the given problem but I realized it's way too slow if you try to do it exactly as it's given in the following text. My question is what ...
-1
votes
1answer
55 views

Method that takes array parameter [duplicate]

I want to implement two methods: AddPlayers and AddPlayer. Is it better when AddPlayers calls AddPlayer or AddPlayer calls AddPlayers with a single item array? Is there a significant difference in ...
5
votes
2answers
521 views

How can arithmetic, like a bit shift, avoid branching?

I'm learning to program the Game Boy Advanced (an old Nintendo console.) I was reading one of the best tutorials about it and it said this about how branching can be done with arithmetic. [To ...
1
vote
1answer
84 views

Create and implement new encoding

I'm working on a project with huge files that contain only the set {[0-9],.}. Encoding in UTF-8 or ASCII make huge files. I wonder if I could find a way to encode in only 4 bits (make those file 16 ...
-3
votes
2answers
383 views

C/C++ code optimization without compilation

Given a simple loop in C or C++ such as the following: for (int i=0, j=0; i<5; i=i*2){ j=j+i*1; } I would like to use a tool (gcc, clang or any other) to optimize the code without actually ...
3
votes
1answer
579 views

Why am I advised to not inline functions that are called only once?

I understand inlining as the following: A separate function which is marked as "inline" (assuming the compiler really does inline) will be "merged" into the function it is called. i.e. (pseudo code)...
2
votes
3answers
1k views

Do any compilers do this optimization for virtual calls?

This just came to mind, and not really sure how to search for this. Let's say you have the following classes class A { public: virtual void Foo() = 0; virtual void ManyFoo(int N) { ...
2
votes
2answers
503 views

How to benchmark software performance under same conditions (RAM, CPU caching etc)?

I am writing a software that splits big files into smaller files and I have coded several solutions. I am measuring the execution time of each of my solutions. (with threads, go routines, MPI etc) ...
1
vote
6answers
253 views

Optimization of iterative loop with removed items

I am translating a piece of software from an old language to c++ and am currently in the optimization stage. The software performs a calculation of loads for several items in a number of timesteps, ...
12
votes
1answer
402 views

Redundant code sent down the pipe with Micro-frontends

My understanding of Micro-frontends is that the key problem they solve is in helping enterprises have multiple, possible disparate teams, work on individual components/small-apps that will be used to ...
0
votes
2answers
141 views

How to build reports for an ecommerce webapp without slowing it down

We have a medium sized ecommerce website which is entirely custom built in using Java and MySQL database on AWS infrastructure. Over a period of past several years, our orders volume has grown ...
0
votes
1answer
77 views

Should I print to the page from a javascript object, or only render from PHP?

I have a complex app on the Javascript/PHP/SQL stack which manages different domain objects. The Javascript layer contains classes which manage the data on the client side. I am currently baking a ...
2
votes
4answers
409 views

What is the optimal way to perform 5000 unique string replace functions in terms of performance?

Restructuring some code, and the way I built it up over time has portions that look something like this: s.replace("ABW"," Aruba "); s.replace("AFG"," Afghanistan "); s.replace("AGO"," Angola "); s....
27
votes
2answers
4k views

Implementation of pure abstract classes and interfaces

Although this isn't mandatory in the C++ standard, it seems the way GCC for example, implements parent classes, including pure abstract ones, is by including a pointer to the v-table for that abstract ...
1
vote
1answer
168 views

Most compact way to represent a graph [closed]

Given these nodes: a b c d e f g h And given some edges between the nodes like this: a/b/c b/c/d c/e c/d/e/f c/g f/g e/f/g a/c/h h/a/b c/a d/b/c f/g/c d/a/f g/f g/a/b/c f/a/b e/a/c (where a/b/c ...
2
votes
1answer
166 views

How to optimize a complex task with multiple DB calls

I have been working on a multi-layer, sale management application developed with WPF and partly refactored with EF6 (long story). The application has some very complex tasks which require multiple ...
21
votes
5answers
15k views

Is passing arguments as const references premature optimization?

"Premature optimization is the root of all evil" I think this we can all agree upon. And I try very hard to avoid doing that. But recently I have been wondering about the practice of passing ...
0
votes
3answers
1k views

Global state variables vs constructor parameter passing

A couple of readonly variables will be used. Almost all of the classes will be using those variables. Either I place all of the variables in a separate internal static class or I pass them on ...
4
votes
3answers
436 views

Using of different language in same project

I was started programming in 6 months ago in college. I learned Python, C and Java. I want to create a project and using these languages. For example to searching part should use C because it's faster ...
2
votes
1answer
383 views

Whole-program optimization

I just asked about the Polyhedral Model, and have looked into other compiler optimizations (Loop unrolling, Constant folding and propagation, Dead code elimination etc.). But I haven't seen anything ...
0
votes
2answers
109 views

Ideal AB testing architecture to optimize for engagement

I'm pushing out a new feature soon that has a lot of different UX components. The key metric that I want to track is user engagement (I have the equation for what this means for me and how to measure ...
5
votes
1answer
685 views

Fastest way to find N closest vectors to vector X in list?

I have a bunch (~20,000) of large (~200 dimensions) vectors in an unsorted list. I can create a new vector of the same size, and I'd like to find the top N (usually 10 or so) closest (defined by ...
-1
votes
1answer
104 views

How to use TypeScript to develop web applications

I've been reading a lot about Type Script lately, and it seems really interesting, but I'm having some trouble understanding how to apply this to my current workflow, so let's start with that. I ...
4
votes
4answers
2k views

Rely on compiler to remove unused code or #ifdef out?

I am working on a USB stack in C. This stack will be open source and used in various different projects. Various configuration options are available, which enable or disable large chunks of code and ...
0
votes
2answers
846 views

MPA vs SPA for first-load performance & meta tags?

Let there be a static web application. Let the following be a priority: First loading time (ignore cache etc) User experience Search Engine Optimization (meta tags & bot friendliness) When ...
19
votes
10answers
2k views

When is it better to optimize a software for better performance, at the beginning or at the end of the development?

I'm a junior software developer and I was wondering when would be the best time to optimize a software for better performance (speed). Assuming the software is not extremely large and complex to ...