optimization

PNG optimisation tools

别等时光非礼了梦想. 提交于 2020-01-09 09:12:13
问题 A while back I used a PNG optimisation service called (I think) "smush it". You fed it a weblink and it returned a zip of all the PNG images with their filesizes nicely, well, smushed... I want to implement a similar optimisation feature as part of my website's image upload process; does anyone know of a pre-existing library (PHP or Python preferably) that I can tap into for this? A brief Google has pointed me towards several command line style tools, but I'd rather not go down that route if

PNG optimisation tools

旧时模样 提交于 2020-01-09 09:08:12
问题 A while back I used a PNG optimisation service called (I think) "smush it". You fed it a weblink and it returned a zip of all the PNG images with their filesizes nicely, well, smushed... I want to implement a similar optimisation feature as part of my website's image upload process; does anyone know of a pre-existing library (PHP or Python preferably) that I can tap into for this? A brief Google has pointed me towards several command line style tools, but I'd rather not go down that route if

Fastest way to produce a mask with n ones starting at position i

杀马特。学长 韩版系。学妹 提交于 2020-01-09 05:18:06
问题 What is the fastest way (in terms of cpu cycles on common modern architecture), to produce a mask with len bits set to 1 starting at position pos : template <class UIntType> constexpr T make_mask(std::size_t pos, std::size_t len) { // Body of the function } // Call of the function auto mask = make_mask<uint32_t>(4, 10); // mask = 00000000 00000000 00111111 11110000 // (in binary with MSB on the left and LSB on the right) Plus, is there any compiler intrinsics or BMI function that can help?

post increment vs pre increment - Javascript Optimization

╄→гoц情女王★ 提交于 2020-01-08 12:27:43
问题 I was browsing Google Code when I chanced upon this project called JSpeed - optimization for Javascript. I noticed one of the optimization was to change i++ to ++i in for loop statements. Before Optimization for (i=0;i<1;i++) {} for (var i = 0, j = 0; i < 1000000; i++, j++) { if (i == 4) { var tmp = i / 2; } if ((i % 2) == 0) { var tmp = i / 2; i++; } } var arr = new Array(1000000); for (i = 0; i < arr.length; i++) {} After optimization for(var i=0;i<1;++i){} for(var i=0,j=0;i<1000000;++i,++j

post increment vs pre increment - Javascript Optimization

我只是一个虾纸丫 提交于 2020-01-08 12:27:24
问题 I was browsing Google Code when I chanced upon this project called JSpeed - optimization for Javascript. I noticed one of the optimization was to change i++ to ++i in for loop statements. Before Optimization for (i=0;i<1;i++) {} for (var i = 0, j = 0; i < 1000000; i++, j++) { if (i == 4) { var tmp = i / 2; } if ((i % 2) == 0) { var tmp = i / 2; i++; } } var arr = new Array(1000000); for (i = 0; i < arr.length; i++) {} After optimization for(var i=0;i<1;++i){} for(var i=0,j=0;i<1000000;++i,++j

Equal loading for parallel task distribution

守給你的承諾、 提交于 2020-01-07 08:19:08
问题 I have a large number of independent tasks I would like to run, and I would like to distribute them on a parallel system such that each processor does the same amount of work, and maximizes my efficiency. I would like to know if there is a general approach to finding a solution to this problem, or possibly just a good solution to my exact problem. I have T=150 tasks I would like to run, and the time each task will take is t=T. That is, task1 takes 1 one unit of time, task2 takes 2 units of

Least square optimization (of matrices) in R

北城余情 提交于 2020-01-07 06:49:12
问题 Yesterday I asked a question about least square optimization in R and it turned out that lm function is the thing that I was looking for. On the other hand, now I have an other least square optimization question and I am wondering if lm could also solve this problem, or if not, how it can be handled in R. I have fixed matrices B (of dimension n x m) and V (of dimension n x n), I am looking for an m -long vector u such that sum( ( V - ( B %*% diag(u) %*% t(B)) )^2 ) is minimized. 回答1: 1) lm

Forcing an index in oracle

放肆的年华 提交于 2020-01-07 06:28:09
问题 I have a query joining lots of fields. For some strange reason the index for one table is not being used at all( I use the index key clearly), instead it is doing a FULL table scan. I would like to force the index. We used to do optimizer hints in sybase. Is there a similar hint available in oracle? For example, in sybase to join tables a, b, c and use myindex in table a, I would do : SELECT a.* FROM a(INDEX myindex), b, c WHERE a.field1 = b.field1 AND b.field1 = c.field1 Question is how do I

Forcing an index in oracle

孤人 提交于 2020-01-07 06:27:19
问题 I have a query joining lots of fields. For some strange reason the index for one table is not being used at all( I use the index key clearly), instead it is doing a FULL table scan. I would like to force the index. We used to do optimizer hints in sybase. Is there a similar hint available in oracle? For example, in sybase to join tables a, b, c and use myindex in table a, I would do : SELECT a.* FROM a(INDEX myindex), b, c WHERE a.field1 = b.field1 AND b.field1 = c.field1 Question is how do I

Optimize Apply() While() in R

一世执手 提交于 2020-01-07 04:38:09
问题 The data below is being used to perform comparative analysis. I wrote the code using apply() and while() , and even though it works as expected, I haven't been successful in optimizing it further. Current run time is more than couple of hours in larger data set. Following is small example data set: data_1 A B C D 2 1 3 2.5 data_2 P Q R S 3 2 4 5.5 Data A B C D 1.0 0.5 1.3 1.5 1.5 1.2 5.5 3.5 1.1 0.5 1.3 1.5 1.5 1.2 5.5 3.5 1.5 1.2 5.5 3.5 1.1 0.5 1.3 1.5 1.5 1.2 5.5 3.5 1.0 0.5 1.3 1.5 Code #