天道酬勤,学无止境

performance

Read size of current document from Javascript

I'm starting to play around with Boomerang for measuring performance. It's very promising. While it allows me to measure latency, bandwidth and page load times, I'm also interested in trying to get the time it took to render the initial HTML page server-side. Wile it seems straightforward to log the time at which the browser started parsing the javascript (which is close to when it initally arrived) in order to get an estimate of the server time, I need to work out how much network time to deduct. So to do that, I need to know how large the html document is. How can I tell this from Javascript

2022-01-19 02:09:10    分类:问答    javascript   performance   dom

What's the benefit of declaring for the loop index variable outside the loop?

I see this in a lot of game engine code. Is this supposed to be faster than if you were to declare it in the for loop body? Also this is followed by many other for loops, each of them using the same variable. int i; for(i=0; i<count; ++i) { } vs for(int i=0; i<count; ++i) { } Btw I never do this myself, just curious about the idea behind it, since apart from performance I don't know why anyone would do this.

2022-01-19 02:00:52    分类:问答    c#   c++   performance   for-loop

Performance hit in int to string conversion, but an object pit stop avoids it

Given a NumPy array of integral type arr = np.random.randint(0, 100, 10**6) why is it (now) faster to take a trip through the object dtype before casting to string? This holds for all integral types. (note this doesn't produce exactly the same type, '<U2' instead of '<U21') >>> %timeit arr.astype(str) 506 ms ± 1.51 ms per loop (mean ± std. dev. of 7 runs, 1 loop each) >>> %timeit arr.astype(object).astype(str) 161 ms ± 1.44 ms per loop (mean ± std. dev. of 7 runs, 10 loops each) It also only seems to be true as of NumPy 1.14.0 - here's the same benchmarks in 1.13.3. >>> %timeit arr.astype(str)

2022-01-19 00:06:07    分类:问答    python   python-3.x   performance   numpy

How can I profile Apache Storm topologies without using the web dashboard?

The title pretty much says it all, I have some Storm topologies and I'd like to measure their latencies, that is, the amount of time between a message coming in from Kafka and the last bit of related execution in the final bolt. Bonus points if I can drill into the results to see the latency across each bolt. Can this be done by simply tweaking the Storm configuration? If not, is http://storm.incubator.apache.org/apidocs/backtype/storm/hooks/info/SpoutAckInfo.html backtype.storm.hooks.info.SpoutAckInfo.completeLatencyMs the thing I'm looking for?

2022-01-18 20:57:01    分类:问答    performance   apache-storm

Most efficient way to populate/distribute indexedDB [datastore] with 350000 records

So, I have a main indexedDB objectstore with around 30.000 records on which I have to run full text search queries. Doing this with the ydn fts plugin this generates a second objectstore with around 300.000 records. Now, as generating this 'index' datastore takes quite long I figured it had be faster to distribute the content of the index as well. This in turn generated a zip file of around 7MB which after decompressing on the client side gives more than 40MB of data. Currently I loop over this data inserting it one by one (async, so callback time is used to parse next lines) which takes

2022-01-18 20:39:22    分类:问答    javascript   performance   indexeddb   ydn-db

Fastest way to find and replace specific line in a large text file with Python

I have a numbers.txt file that consists of several 100K lines, each one made up of two unique digits separated with : sign: 407597693:1604722326.2426915 510905857:1604722326.2696202 76792361:1604722331.120079 112854912:1604722333.4496727 470822611:1604722335.283259 My goal is to locate a line with the number 407597693 on the left side and then proceed to change the number on the right side by adding 3600 to it. After that, I have to rewrite the numbers.txt file with all the changes. I must perform the same (just different number) operation on the same txt file as fast as possible. I have

2022-01-18 19:34:49    分类:问答    python   performance   optimization   io   full-text-search

Write an efficient string replacement function?

For the purpose of learning I've tried to come up with a string replacement function, here's what I have now: let string_replace where what replacement = let wlength = (String.length what - 1) in let length = (String.length where - 1) in let rec loop i shift = let [shift, i] = if wlength == shift then (String.blit replacement 0 where (i - wlength) (wlength + 1); [0, i]) else if (String.get where i == String.get what shift) then [shift + 1, i] else [0, i - shift] in if i < length then loop (i + 1) shift in loop 0 0; where;; Now, there's a test here: http://raid6.com.au/~onlyjob/posts/arena/ and

2022-01-18 19:10:26    分类:问答    performance   ocaml

Image Rendering Test

I am benchmarking a custom brower and want to benchmark the rendering speeds of different types of images (gif, jpg, png) of the same file size to see which of the image formats this browser renders the fastest. My process was just to have a simple seperate HTML page for each type of image and just use a Javascript counter before it is rendered and and after to measure the browser's rendering speed of that specific image. Any thoughts on this process? Any thoughts on how to improve it?

2022-01-18 18:47:41    分类:问答    performance   image   rendering

IEnumerable as DataTable performance issue

I have the following extension, which generates a DataTable from an IEnumerable: public static DataTable AsDataTable<T>(this IEnumerable<T> enumerable) { DataTable table = new DataTable(); T first = enumerable.FirstOrDefault(); if (first == null) return table; PropertyInfo[] properties = first.GetType().GetProperties(); foreach (PropertyInfo pi in properties) table.Columns.Add(pi.Name, pi.PropertyType); foreach (T t in enumerable) { DataRow row = table.NewRow(); foreach (PropertyInfo pi in properties) row[pi.Name] = t.GetType().InvokeMember(pi.Name, BindingFlags.GetProperty, null, t, null)

2022-01-18 18:12:38    分类:问答    c#   linq   performance   datatable   ienumerable

Strange performance behaviour for 64 bit modulo operation

The last three of these method calls take approx. double the time than the first four. The only difference is that their arguments doesn't fit in integer anymore. But should this matter? The parameter is declared to be long, so it should use long for calculation anyway. Does the modulo operation use another algorithm for numbers>maxint? I am using amd athlon64 3200+, winxp sp3 and vs2008. Stopwatch sw = new Stopwatch(); TestLong(sw, int.MaxValue - 3l); TestLong(sw, int.MaxValue - 2l); TestLong(sw, int.MaxValue - 1l); TestLong(sw, int.MaxValue); TestLong(sw, int.MaxValue + 1l); TestLong(sw, int

2022-01-18 17:56:00    分类:问答    c++   performance   64-bit   numeric