optimization

char[] to hex string exercise

北慕城南 提交于 2020-01-11 05:17:47
问题 Below is my current char* to hex string function. I wrote it as an exercise in bit manipulation. It takes ~7ms on a AMD Athlon MP 2800+ to hexify a 10 million byte array. Is there any trick or other way that I am missing? How can I make this faster? Compiled with -O3 in g++ static const char _hex2asciiU_value[256][2] = { {'0','0'}, {'0','1'}, /* snip..., */ {'F','E'},{'F','F'} }; std::string char_to_hex( const unsigned char* _pArray, unsigned int _len ) { std::string str; str.resize(_len*2);

Does compiler perform “return value optimization” on chains of async methods

眉间皱痕 提交于 2020-01-11 05:12:26
问题 Not return value optimization in the traditional sense, but I was wondering when you have a situation like this: private async Task Method1() { await Method2(); } private async Task Method2() { await Method3(); } private async Task Method3() { //do something async } This could obviously be written more optimally: private Task Method1() { return Method2(); } private Task Method2() { return Method3(); } private async Task Method3() { //do something async } I just wondered whether anyone knew if

Does compiler perform “return value optimization” on chains of async methods

99封情书 提交于 2020-01-11 05:12:05
问题 Not return value optimization in the traditional sense, but I was wondering when you have a situation like this: private async Task Method1() { await Method2(); } private async Task Method2() { await Method3(); } private async Task Method3() { //do something async } This could obviously be written more optimally: private Task Method1() { return Method2(); } private Task Method2() { return Method3(); } private async Task Method3() { //do something async } I just wondered whether anyone knew if

Excel VBA efficient get file names function

荒凉一梦 提交于 2020-01-11 04:55:08
问题 I need to get a collection of file names from a folder on a remote server using VBA in excel 2010. I have a function that works and in the majority of cases it would do the job, however the remote server frequently has terrible, terrible network performance issues. This means that looping through say 300 files to put their names into a collection can take 10 minutes, the number of files in the folder is likely to grow to thousands so this is not workable, I need a way to get all of the file

faster Math.exp() via JNI?

这一生的挚爱 提交于 2020-01-11 04:40:07
问题 I need to calculate Math.exp() from java very frequently, is it possible to get a native version to run faster than java 's Math.exp() ?? I tried just jni + C, but it's slower than just plain java . 回答1: +1 to writing your own exp() implementation. That is, if this is really a bottle-neck in your application. If you can deal with a little inaccuracy, there are a number of extremely efficient exponent estimation algorithms out there, some of them dating back centuries. As I understand it, Java

Constrained least-squares estimation in Python

霸气de小男生 提交于 2020-01-11 04:30:28
问题 I'm trying to perform a constrained least-squares estimation using Scipy such that all of the coefficients are in the range (0,1) and sum to 1 (this functionality is implemented in Matlab's LSQLIN function). Does anybody have tips for setting up this calculation using Python/Scipy. I believe I should be using scipy.optimize.fmin_slsqp() , but am not entirely sure what parameters I should be passing to it.[1] Many thanks for the help, Nick [1] The one example in the documentation for fmin

global vs. local namespace performance difference

萝らか妹 提交于 2020-01-10 19:25:48
问题 Why is it that executing a set of commands in a function: def main(): [do stuff] return something print(main()) will tend to run 1.5x to 3x times faster in python than executing commands in the top level: [do stuff] print(something) 回答1: The difference does indeed greatly depend on what "do stuff" actually does and mainly on how many times it accesses names that are defined/used. Granted that the code is similar, there is a fundamental difference between these two cases: In functions, the

Tuning MySQL for speedy column/index creation during development

早过忘川 提交于 2020-01-10 16:26:10
问题 Assume a MySQL MyISAM table with one gigabyte of data and one gigabyte of indexes. Furthermore, assume that during development columns and indexes will be added and removed from/to the table quite frequently. Due to the size of the database the column/index creation is slow when using the standard non-tuned MySQL settings. Which MySQL server parameters should be tuned in order to minimize the time it takes to add new columns/indexes? 回答1: I believe the key settings you should look at are key

Tuning MySQL for speedy column/index creation during development

此生再无相见时 提交于 2020-01-10 16:24:49
问题 Assume a MySQL MyISAM table with one gigabyte of data and one gigabyte of indexes. Furthermore, assume that during development columns and indexes will be added and removed from/to the table quite frequently. Due to the size of the database the column/index creation is slow when using the standard non-tuned MySQL settings. Which MySQL server parameters should be tuned in order to minimize the time it takes to add new columns/indexes? 回答1: I believe the key settings you should look at are key

Proper way to handle 'optional' where clause filters in SQL?

做~自己de王妃 提交于 2020-01-10 15:39:46
问题 Let's say you have a stored procedure, and it takes an optional parameter. You want to use this optional parameter in the SQL query. Typically this is how I've seen it done: SELECT * FROM dbo.MyTableName t1 WHERE t1.ThisField = 'test' AND (@MyOptionalParam IS NULL OR t1.MyField = @MyOptionalParam) This seems to work well, however it causes a high amount of logical reads if you run the query with STATISTICS IO ON. I've also tried the following variant: SELECT * FROM dbo.MyTableName t1 WHERE t1