optimization

Xib taking long time (>1s) to load. UIFont cache seems to blame

北战南征 提交于 2020-01-22 13:53:29
问题 I have a UIVC loading from a Storyboard which, in turn, loads a Xib. This inner load is causing the VC to take more than a second to load. There is some fancy footwork going on in the inner xib (it loads another xib which has dynamic drawing) but this doesn't appear to be the bottleneck. According to Instruments, UIFont -initWithCoder is the culprit. (If you drill down further TBaseFont::CopyLocalizedName() is the deepest entry that accounts for the majority of the 1s time) I'm a bit stumped

Using ThreadStatic to replace expensive locals — good idea?

…衆ロ難τιáo~ 提交于 2020-01-22 08:57:24
问题 Update : as I should have expected, the community's sound advice in response to this question was to "measure it and see." chibacity posted an answer with some really nice tests that did this for me; meanwhile, I wrote a test of my own; and the performance difference I saw was actually so huge that I felt compelled to write a blog post about it. However, I should also acknowledge Hans's explanation that the ThreadStatic attribute is indeed not free and in fact relies on a CLR helper method to

What is the fastest search method for a sorted array?

╄→гoц情女王★ 提交于 2020-01-22 05:03:08
问题 Answering to another question, I wrote the program below to compare different search methods in a sorted array. Basically I compared two implementations of Interpolation search and one of binary search. I compared performance by counting cycles spent (with the same set of data) by the different variants. However I'm sure there is ways to optimize these functions to make them even faster. Does anyone have any ideas on how can I make this search function faster? A solution in C or C++ is

optim function argument missing

徘徊边缘 提交于 2020-01-21 11:42:54
问题 This is my code. The kum.loglik function returns negative loglikelihood and takes two arguments a and b. I need to find a and b that minimize this function using optim function. (n1,n2,n3 is pre-specified and passed to optim function. kum.loglik = function(a, b, n1, n2, n3) { loglik = n1*log(b*beta(1+2/a,b)) + n2 * log(b*beta(1+2/a,b)-2*b*beta(1+1/a,b)+1) + n3 * log(b*beta(1+1/a,b)-b*beta(1+2/a,b)) return(-loglik) } optim(par=c(1,1), kum.loglik, method="L-BFGS-B", n1=n1, n2=n2, n3=n3, control

Optimisation of division in gcc

心不动则不痛 提交于 2020-01-21 10:52:11
问题 Here's some code (full program follows later in the question): template <typename T> T fizzbuzz(T n) { T count(0); #if CONST const T div(3); #else T div(3); #endif for (T i(0); i <= n; ++i) { if (i % div == T(0)) count += i; } return count; } Now, if I call this template function with int , then I get a factor of 6 performance difference according to whether I define CONST or not: $ gcc --version gcc (GCC) 3.4.4 (cygming special, gdc 0.12, using dmd 0.125) $ make -B wrappedint CPPFLAGS="-O3

Analysing solution (.sol) file in pyomo

眉间皱痕 提交于 2020-01-21 10:35:28
问题 I have a model in pyomo in say machine 1 and I have the CPLEX solver in machine 2. I convert the pyomo model ( ConcreteModel ) into a problem.lp file with function model.write("problem.lp") in machine 1. Then I transfer this file to machine 2 and get the solution.sol file from the CPLEX solver. But names of the variables in the solution file is different from the names of the variables of the model. This is causing a problem in analysis of the solution. Is there any way to convert or map the

Force compiler to not optimize side-effect-less statements

谁说胖子不能爱 提交于 2020-01-21 06:31:07
问题 I was reading some old game programming books and as some of you might know, back in that day it was usually faster to do bit hacks than do things the standard way. (Converting float to int , mask sign bit, convert back for absolute value, instead of just calling fabs() , for example) Nowadays is almost always better to just use the standard library math functions, since these tiny things are hardly the cause of most bottlenecks anyway. But I still want to do a comparison, just for curiosity

Force compiler to not optimize side-effect-less statements

吃可爱长大的小学妹 提交于 2020-01-21 06:30:31
问题 I was reading some old game programming books and as some of you might know, back in that day it was usually faster to do bit hacks than do things the standard way. (Converting float to int , mask sign bit, convert back for absolute value, instead of just calling fabs() , for example) Nowadays is almost always better to just use the standard library math functions, since these tiny things are hardly the cause of most bottlenecks anyway. But I still want to do a comparison, just for curiosity

Finding lists of prime numbers with SIMD - SSE/AVX

余生长醉 提交于 2020-01-21 05:26:05
问题 I'm curious if anyone has advice on how to use SIMD to find lists of prime numbers. Particularly I'm interested how to do this with SSE/AVX. The two algorithms I have been looking at are trial division and the Sieve of Eratosthenes. I have managed to find a way to use SSE with trial division. I found a faster way to to division which works well for a vector/scalar "Division by Invariant Integers Using Multiplication"http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.1.2556 Each time I

Skip forbidden parameter combinations when using GridSearchCV

为君一笑 提交于 2020-01-21 04:20:24
问题 I want to greedily search the entire parameter space of my support vector classifier using GridSearchCV. However, some combinations of parameters are forbidden by LinearSVC and throw an exception. In particular, there are mutually exclusive combinations of the dual , penalty , and loss parameters: For example, this code: from sklearn import svm, datasets from sklearn.model_selection import GridSearchCV iris = datasets.load_iris() parameters = {'dual':[True, False], 'penalty' : ['l1', 'l2'], \