benchmarking

Python, using multiprocess is slower than not using it

不打扰是莪最后的温柔 提交于 2019-11-30 05:12:45
After spending a lot of time trying to wrap my head around multiprocessing I came up with this code which is a benchmark test: Example 1: from multiprocessing import Process class Alter(Process): def __init__(self, word): Process.__init__(self) self.word = word self.word2 = '' def run(self): # Alter string + test processing speed for i in range(80000): self.word2 = self.word2 + self.word if __name__=='__main__': # Send a string to be altered thread1 = Alter('foo') thread2 = Alter('bar') thread1.start() thread2.start() # wait for both to finish thread1.join() thread2.join() print(thread1.word2)

C++ Array vs Vector performance test explanation [closed]

对着背影说爱祢 提交于 2019-11-30 04:30:01
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . In order to quantify the difference in performance of a C-like array and Vectors in C++, I wrote this little program. https://github.com/rajatkhanduja/Benchmarks/blob/master/C%2B%2B/vectorVsArray.cpp To compare

Clojure number crunching performance

本秂侑毒 提交于 2019-11-30 03:42:18
I'm not sure whether this belongs on StackOverflow or in the Clojure Google group. But the group seems to be busy discussing numeric improvements for Clojure 1.2 , so I'll try here: http://shootout.alioth.debian.org/ has a number of performance benchmarks for various languages. I noticed that Clojure was missing, so I made a Clojure version of the n-body problem . The fastest code I was able to produce can be found here , and benchmarking it seems to be saying that for number crunching Clojure is factor ~10 quicker than Python/Ruby/Perl factor ~4 slower than C/Java/Scala/Ada approximately on

Why is == faster than eql?

北慕城南 提交于 2019-11-30 03:22:43
I read in the documentation for the String class that eql? is a strict equality operator, without type conversion, and == is a equality operator which tries to convert second its argument to a String, and, the C source code for this methods confirms that: The eql? source code: static VALUE rb_str_eql(VALUE str1, VALUE str2) { if (str1 == str2) return Qtrue; if (TYPE(str2) != T_STRING) return Qfalse; return str_eql(str1, str2); } The == source code: VALUE rb_str_equal(VALUE str1, VALUE str2) { if (str1 == str2) return Qtrue; if (TYPE(str2) != T_STRING) { if (!rb_respond_to(str2, rb_intern("to

What's the best way to determine at runtime if a browser is too slow to gracefully handle complex JavaScript/CSS?

混江龙づ霸主 提交于 2019-11-30 01:59:58
I'm toying with the idea of progressively enabling/disabling JavaScript (and CSS) effects on a page - depending on how fast/slow the browser seems to be. I'm specifically thinking about low-powered mobile devices and old desktop computers -- not just IE6 :-) Are there any examples of this sort of thing being done? What would be the best ways to measure this - accounting for things, like temporary slowdowns on busy CPUs? Notes: I'm not interested in browser/OS detection. At the moment, I'm not interested in bandwidth measurements - only browser/cpu performance. Things that might be interesting

Measure (max) memory usage with IPython—like timeit but memit

ぐ巨炮叔叔 提交于 2019-11-30 00:43:17
I have a simple task: in addition to measuring the time it takes to execute a chunk of code in Python, I need to measure the amount of memory a given chunk of code needs. IPython has a nice utility called timeit which works like this: In [10]: timeit 3 + 3 10000000 loops, best of 3: 24 ns per loop What I'm looking for is something like this: In [10]: memit 3 + 3 10000000 loops, best of 3: 303 bytes per loop I'm aware that this probably does not come built in with IPython—but I like the timeit - memit analogy. Thomas K In fact, it already exists, as part of the pragmatically named memory

benchmarks: does python have a faster way of walking a network folder?

好久不见. 提交于 2019-11-29 23:54:14
I need to walk through a folder with approximately ten thousand files. My old vbscript is very slow in handling this. Since I've started using Ruby and Python since then, I made a benchmark between the three scripting languages to see which would be the best fit for this job. The results of the tests below on a subset of 4500 files on a shared network are Python: 106 seconds Ruby: 5 seconds Vbscript: 124 seconds That Vbscript would be slowest was no surprise but I can't explain the difference between Ruby and Python. Is my test for Python not optimal? Is there a faster way to do this in Python

Can someone please explain what these ApacheBench results mean?

只愿长相守 提交于 2019-11-29 22:30:13
i'm trying to figure out how to use ApacheBench and benchmark my website. I installed the default site project (it's ASP.NET MVC but please don't put stop reading if u're not a .NET person). I didn't change anything. Add new project. Set confuration to RELEASE. Run without Debug. (so it's in LIVE mode). Yes, this is with the built in webserver, not the production grade IIS or Apache or whatever. So here's the results :- C:\Temp>ab -n 1000 -c 1 http://localhost:50035/ This is ApacheBench, Version 2.3 <$Revision: 655654 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

benchmarking, code reordering, volatile

試著忘記壹切 提交于 2019-11-29 22:27:56
I decide I want to benchmark a particular function, so I naïvely write code like this: #include <ctime> #include <iostream> int SlowCalculation(int input) { ... } int main() { std::cout << "Benchmark running..." << std::endl; std::clock_t start = std::clock(); int answer = SlowCalculation(42); std::clock_t stop = std::clock(); double delta = (stop - start) * 1.0 / CLOCKS_PER_SEC; std::cout << "Benchmark took " << delta << " seconds, and the answer was " << answer << '.' << std::endl; return 0; } A colleague pointed out that I should declare the start and stop variables as volatile to avoid

how would you benchmark the performance of a function

一世执手 提交于 2019-11-29 21:44:19
问题 here's perhaps a more advanced question. if you have two functions that return a value int F(int input1, int input2) { int output; //some algorithm that assigns value to output// return output; } int D(int input1, int input2) { int output; //another algorithm that assigns value to output// return output; } With the condition that F(a,b) == D(a,b) (both return the same value for the same inputs). If you'd like to benchmark their performance, how would you do it? More precisely, how would you