оптимизация

Which is faster: vector traversal or list traversal?

At the interview, they asked: which is faster, traversing a vector or traversing a list with values output to the console? Ho ... thing to do with the first? If the entire vector or list does not get into the cache, will the container crawl time increase?

Optimizing the tmp variable in a function

Please tell me what optimization the compiler will perform in this code: void MyClass::clear() noexcept { MyClass tmp; ... ing. void MyClass::swap(MyClass& other) noexcept { using std::swap; swap(this->m_number, other.m_number); }

How to optimize (speed up) this part of the code as much as possible?

trgba = record r,g,b,a:byte; end; function q(backcl,forecl):trgba; var factor:real; begin if forecl.a=0 then begin ... .b*factor); result.g:=trunc(backcl.g*(1-factor)+forecl.g*factor); result.r:=trunc(backcl.r*(1-factor)+forecl.r*factor); end;

Why is subtraction faster than addition?

I wrote several benchmarks for the vector (I used the Google library https://github.com/google/benchmark) and got a strange r ... with zeros than with large numbers, but then the question arises, why does not the difference decrease on small ones numbers.

Optimization of the SQL query. Can I replace UNION?

Let's say there is an abstract query for a report like this: select 'Общие затраты', SUM(price1) as field11,SUM(price2) as f ... an see from the plan, the repeated reading was lost, but the execution time was higher the option that @MaxU suggested above.

How to create a gradient background for the entire web page?

Please tell me if it is possible to use gradients (or some other technology) to make a background image-a background for the ... and I do not want to throw in 3mB, and when compressing this photo I lose the quality) the biggest problem with clouds.

Why is the draw call expensive?

There are a lot of ways to optimize the number of rendering calls. For example, it can be a batching or a texture atlas. It i ... ng possible to the GPU at a time than to send it in pieces. But why? Will the final amount of work required change from this?

Location of objects by mathematical function in a loop (optimization)

Good time of day. I have some list of objects, and they need to be arranged in a semicircle relative to a certain center: Th ... its and precision? Or is there a way to quickly run through a mathematical function? Thank you in advance for your answer.

Shrink or trim the MS SQL 2012 database

There is a database in MS SQL 2012 with a size of ~130 GB. The problem is that in compressed form it takes 9 GB, and if you u ... 1C, we get up to ~3 GB. Shrink by means of MS SQL removes only 2 MB of data. How can I diagnose or find and fix the problem?

Code optimization (Kruskal algorithm)

Task-implementation of the Kruskal algorithm for calculating the minimum total length of tracks in an amusement park. The ti ... et(i).y)); count++; } } System.out.printf("%.2f", MST(result, edges)); } }

Error in python pandas, "A value is trying to be set on a copy of a slice from a DataFrame"

I run the creation of a new column in pandas in a loop (12k values). And gives this error: C:\ProgramData\Anaconda3\lib\s ... : t.loc[i]=0 It gives an error, but in general it counts, but for a very long time...can you tell me how to fix it?

Optimizing the app for tablets

Created and uploaded the app to the market. A few hours after the publication, we received a notification that it was not opt ... can it be optimized? The appearance of the screens is schematically depicted in the picture What exactly should I optimize?

Numeric sequence

Initially, the string "0" is given, then at each iteration, instead of the original string, a new sequence is created, 2 time ... else: a.append(int(i)+1) str_tp = ''.join(map(str, a)) string = string[::-1] + str_tp print(string[k-1])

How can I profile my code in windows 7

I want to learn how to profile the code in PyCharm in windows 7. But I can't open the files in any way .prof in windows. As f ... omial(n, f))) n -= 1 return out It starts to slow down if you run the function with the following arguments-n=1921, k=5

Quick ways to find all primes less than N

What are the algorithms for the fastest finding of all primes less than N, except for the well-known ones: The Sieve of Era ... on is related to the constantly emerging new questions about the effective implementation of finding all primes less than N.

SQRT decomposition 2D

There is an area of a given size, where N points are specified, and their coordinates are given. You need to learn how to qui ... e usual one-dimensional sqrt decomposition, everything is simple, because the index is converted there, but what about here?