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
-2
votes
0answers
20 views

How to optimize the check for data types before building an object?

I'm trying to build an object, which uses different methods based on different data types. I.e. it differs from withBooleanValue,withStringValue and withDateValue depending on the data type. What I ...
0
votes
2answers
100 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
0answers
34 views

Optimization Algorithm for Patterns

(Private feedback for you) I am trying to develop a solution to problem, as follows: I have a set of patterns, numbered for P1 to P12. Each pattern will produce a number of different pieces (labelled ...
-2
votes
3answers
122 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 ...
1
vote
0answers
68 views

Optimization algorithm seems biased

I've written an algorithm designed to solve a minimization problem which can be demonstrated with the following simple example: I have three observers (who's locations are known) and one or more ...
0
votes
3answers
108 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 ...
1
vote
0answers
52 views

How to efficiently map unknown vector fields

I've got a problem I've been wrestling with, and I'm really truly stuck: I have a bounded, continuous vector field and my goal is to map it using discrete measurements at specific points. I can only ...
-3
votes
2answers
65 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 ...
-3
votes
1answer
53 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; ...
-2
votes
1answer
27 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 ...
0
votes
1answer
80 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 ...
1
vote
5answers
607 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 ...
-3
votes
2answers
39 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 ...
1
vote
1answer
40 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, ...
0
votes
1answer
65 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 ...
3
votes
2answers
167 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 ...
7
votes
2answers
178 views

How does conditional compilation impact product quality, security and code complexity? [closed]

Software libraries targetting resource constrained environments like embedded systems use conditional compilation to allow consumers to shave space by removing unused features from the final binaries ...
-3
votes
2answers
62 views

How specific is hardware optimization when building from source/how do I know?

How specific is hardware optimization when building from source and what should I look for in the documentation to decide if building for my hardware might be worth it? From threads like this one I ...
-2
votes
1answer
50 views

Finding the domain(s) of variables in a Linear Program using the constraints? (Constraint programming/Linear programming)

Forgive my jargon , as I'm not very familiar with Constraint Satisfaction Problem(s) or Linear Programming procedures (For eg: Presolve) I have very trivial constraint set from variables of ...
-2
votes
1answer
74 views

Server-side vs. Client-side markup - whichi is more efficient?

The background of this question is stemming from an article about someone who operates a website that is powered by a solar panel and the carbon footprint that we produce in the software space. Data ...
7
votes
8answers
669 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
238 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 ...
5
votes
1answer
201 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
86 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 ...
4
votes
6answers
1k 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
110 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
117 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
241 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 ...
1
vote
2answers
226 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
245 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
490 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
109 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
118 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
155 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
353 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
335 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
158 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
796 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
82 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 ...
1
vote
2answers
114 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
568 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 ...
-1
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 ...
6
votes
3answers
801 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
101 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
484 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 ...
4
votes
3answers
973 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
2k 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
724 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
2 3 4 5
8