optimization

Can one express catamorphism through Data.Function.fix?

吃可爱长大的小学妹 提交于 2020-02-04 05:33:29
问题 I have this lovely fixana function here that performs about 5 times faster than her sister ana . (i have a criterion report to back me on this) ana alg = Fix . fmap (ana alg) . alg fixana alg = fix $ \f -> Fix . fmap f . alg Can I express their cousin cata in the same fashion? cata f = f . fmap (cata f) . unFix It seems to me that I cannot, but I have been humbled by my S.O. fellows quite a few times in the past. 回答1: Actually, this has nothing to do with catamorphisms. Whenever a function is

Optimize mysql query for date group

微笑、不失礼 提交于 2020-02-04 01:24:13
问题 This my tables: CREATE TABLE IF NOT EXISTS `test_dates` ( `date` date NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE IF NOT EXISTS `test_log` ( `id` int(10) unsigned NOT NULL, `timest` datetime NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; ALTER TABLE `test_dates` ADD PRIMARY KEY (`date`); ALTER TABLE `test_log` ADD PRIMARY KEY (`id`), ADD KEY `emissione` (`timest`); I have this query to count logs per date: SELECT d.date, COUNT(l.id) FROM test_dates d LEFT JOIN test_log l ON l

Python data structures overhead/performance

有些话、适合烂在心里 提交于 2020-02-04 00:14:33
问题 Is there any performance advantage to using lists over dictionaries over tuples in Python? If I'm optimising for speed, is there any reason to prefer one over another? 回答1: Rich, Lists and dicts are beasts suitable for different needs. Make sure you don't use lists for linear searches where dicts hashes are perfect, because it's way slower. Also, if you just need a list of elements to traverse, don't use dicts because it will take much more space than lists. That may sound obvious, but

PHP and MySQL: optimize database

对着背影说爱祢 提交于 2020-02-03 09:44:23
问题 I have a database with over 10,000,000 rows. Querying it right now can take a few seconds just to find some basic information. This isn't preferable, I know that the best way to optimize is to minimize the number of rows which is possible, but right now I don't have the time to do this. What's the easiest way to optimize a MySQL database so that when querying it, the time taken is short? I don't mind about the size of the database, that doesn't really matter so any optimizations that increase

Compiler Hints and Semantics for Optimizations [closed]

断了今生、忘了曾经 提交于 2020-02-03 09:44:10
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 3 years ago . I spent the last couple of weeks optimizing a numerical algorithm. Through a combination of precomputation, memory alignment, compiler hints and flags, and trial and error experimentation, I brought the run-time down over an order of magnitude. I have not yet explicitly vectorized

PHP and MySQL: optimize database

不问归期 提交于 2020-02-03 09:44:05
问题 I have a database with over 10,000,000 rows. Querying it right now can take a few seconds just to find some basic information. This isn't preferable, I know that the best way to optimize is to minimize the number of rows which is possible, but right now I don't have the time to do this. What's the easiest way to optimize a MySQL database so that when querying it, the time taken is short? I don't mind about the size of the database, that doesn't really matter so any optimizations that increase

Can -ffast-math be safely used on a typical project?

ε祈祈猫儿з 提交于 2020-02-03 03:06:13
问题 While answering a question where I suggested -ffast-math , a comment pointed out that it is dangerous. My personal feeling is that outside scientific calculations, it is OK. I also asume that serious financial applications use fixed point instead of floating point. Of course if you want to use it in your project the ultimate answer is to test it on your project and see how much it affects it. But I think a general answer can be given by people who tried and have experience with such

How to set upper and lower bounds for each element in a set?

断了今生、忘了曾经 提交于 2020-02-02 13:35:06
问题 I am creating a GAMS model to solve a simple maximization problem. I have a set J with 3 elements (1,2,3) and a variable x(J) that encompasses all the elements. I am wondering if there is a way in GAMS to set a lower bound of 0 and upper bound of 3 to each element in the set without having to set each element bound individually and without using the positive variable keyword for the lower bound. I have tried using x.lo =e= 0 and x.up =e= 3 but none of these are working. I am guessing I am not

How to set upper and lower bounds for each element in a set?

纵然是瞬间 提交于 2020-02-02 13:31:37
问题 I am creating a GAMS model to solve a simple maximization problem. I have a set J with 3 elements (1,2,3) and a variable x(J) that encompasses all the elements. I am wondering if there is a way in GAMS to set a lower bound of 0 and upper bound of 3 to each element in the set without having to set each element bound individually and without using the positive variable keyword for the lower bound. I have tried using x.lo =e= 0 and x.up =e= 3 but none of these are working. I am guessing I am not

how to optimize this javascript code?

南楼画角 提交于 2020-02-02 12:01:07
问题 How to optimize this functions? Can I make one function for all operations? $('#b-hat1').click(function() { $('#hat3').hide(); $('#hat2').hide(); $('#hat1').show(); }); $('#b-hat2').click(function() { $('#hat3').hide(); $('#hat2').show(); $('#hat1').hide(); }); $('#b-hat3').click(function() { $('#hat3').show(); $('#hat2').hide(); $('#hat1').hide(); }); 回答1: Without your html, i can only give you a "rought" idea about how to solve it. $("div[id^='hat']").hide(); hides all the div's that starts