optimization

Is there any extra cost of calling non-virtual base methods in virtual inheritance?

牧云@^-^@ 提交于 2020-01-03 02:41:12
问题 I had referred this question (I changed its title). I am aware that code generation related to virtual ness are implementation specific. However, earlier question suggests that, there is an additional cost related to virtual inheritance, when calling non-virtual base method. I wrote following test codes and checked its assembly in g++ (with -O4 ): Common part struct Base { int t_size; Base (int i) : t_size(i) {} virtual ~Base () {} int size () const { return t_size; }; }; struct D1 : virtual

Optimizing 1D Convolution

守給你的承諾、 提交于 2020-01-03 02:28:10
问题 Is there a way to speed up this 1D convolution ? I tried to make the dy cache efficient but compiling with g++ and -O3 gave worse performances. I am convolving with [-1. , 0., 1] in both directions. Is not homework. #include<iostream> #include<cstdlib> #include<sys/time.h> void print_matrix( int height, int width, float *matrix){ for (int j=0; j < height; j++){ for (int i=0; i < width; i++){ std::cout << matrix[j * width + i] << ","; } std::cout << std::endl; } } void fill_matrix( int height,

Is there a better solution than CSS sprites?

南笙酒味 提交于 2020-01-03 02:22:34
问题 this is not a question about a specific programming problem, it's about examining different concepts. If the moderators don't feel this is ok, delete my question. I need to display 100 png images in a table td, and the images are 75x16 PNGs. In order to reduce the number of HTTP requests, I grouped all 166 images (only roughly 100 are shown at one time) in a big spritesheet, and have used the IMG tag to display the output, one image at a time. This is the code: CSS: .sprites {background-image

Will this work on all screen sizes?

≡放荡痞女 提交于 2020-01-03 01:58:08
问题 I've been doing lots of research lately on optimizing my app for all screen sizes. I've created 9 of every layout in order to fit every size. Don't worry about those other two layouts that are just in the layout directory, I will make 8 more of those later (Android view) Some articles say to have more layouts, but of what? Am I missing something? Did I do this correctly? I have some doubt about my screen sizes, as lots of people on the internet have different ways of targeting different

Defer unused CSS

跟風遠走 提交于 2020-01-03 01:34:07
问题 I have a critcal CSS process in place that prevents a flash-of-unstyled-content (FOUC) on above-the-fold content of a page. I'm stuck on 'defer unused CSS' point that's being highlighted by Google PageSpeed insights (lighthouse) and/or Chrome's Performance Audit. I've gone through other articles but they do not work. To summarize I've tried so far. loadCSS() A script that uses requestAnimationFrame Ref: CSS delivery optimization: How to defer css loading? If I delay loading the script via

2D OpenGL scene slows down with lots of overlapping shapes

纵然是瞬间 提交于 2020-01-03 01:20:07
问题 I'm drawing 2D shapes with OpenGL. They aren't using that many polygons. I notice that I can have lots and lots of shapes as long as they don't overlap. If I get a shape behind a shape behind.... etc.. it really starts lagging. I feel like I might be doing something wrong. Is this normal and is there a way to fix this (I can't omit rendering because I do blending for alpha). I also have CW backface culling enabled. Thanks 回答1: Are your two cases (overlapping and non-overlapping) using the

Using C++ function templates for a group of functions

别等时光非礼了梦想. 提交于 2020-01-03 00:40:53
问题 I have different functions for square matrix multiplication depending on matrix size which varies from 8x8 through 20x20. The functions differ from each other because each employ different strategies for optimization, namely, different loop permutations and different loop unroll factors. Matrix size is invariant during the life of a program. My goal is to reduce the time to decide which function must be used. For example, a naive implementation is: if (matrixSize == 8) C = mxm8(A, B); else if

Retrieve a specific permutation without storing all possible permutations in Matlab

谁都会走 提交于 2020-01-03 00:37:22
问题 I am working on 2D rectangular packing. In order to minimize the length of the infinite sheet (Width is constant) by changing the order in which parts are placed. For example, we could place 11 parts in 11! ways. I could label those parts and save all possible permutations using perms function and run it one by one, but I need a large amount of memory even for 11 parts. I'd like to be able to do it for around 1000 parts. Luckily, I don't need every possible sequence. I would like to index

How can i optimize this jquery code

本秂侑毒 提交于 2020-01-02 23:16:06
问题 Is there a shorter more optimized way to write the following code. $("button.idiv").click(function(){ var elm = $('<div id=divid' + divId + ' class=aaa></div>'); elm.resizable().draggable({ containment: "p", stack:"div" }).appendTo('p'); divId++; }); $("button.ispan").click(function(){ var elm = $('<img id=spanid' + spanId + ' class=aaas src="Dollar.png"/>'); elm.resizable().parent().draggable({ containment: "p", stack:"div" }).appendTo('p'); spanId++; }); $("button.itext").click(function(){

RequireJS Optimization

微笑、不失礼 提交于 2020-01-02 20:29:10
问题 I`m using r.js to optimize my app, as i saw in several samples, i used build.json configuration file to config my optimization options. The problem is that when i set reference to the output javascript file after optimization I`m getting the following error in the browser: Uncaught ReferenceError: define is not defined main-built.js:14735 Looks like, all my app modules are exists but RequireJs is missing. This is my build.json configuration file: { "baseUrl": "../", "name": "src/modules/main"