How do cache lines work?

If the cache line containing the byte or word you’re loading is not already present in the cache, your CPU will request the 64 bytes that begin at the cache line boundary (the largest address below the one you need that is multiple of 64). Modern PC memory modules transfer 64 bits (8 bytes) at … Read more

Process very large (>20GB) text file line by line

It’s more idiomatic to write your code like this def ProcessLargeTextFile(): with open(“filepath”, “r”) as r, open(“outfilepath”, “w”) as w: for line in r: x, y, z = line.split(‘ ‘)[:3] w.write(line.replace(x,x[:-3]).replace(y,y[:-3]).replace(z,z[:-3])) The main saving here is to just do the split once, but if the CPU is not being taxed, this is likely to make … Read more

How to draw an updating line

You need to have two drawing calls: One for the non-persistent line that follows the cursor in the MouseMove using someControls.CreateGraphics the other for the persisting line, triggered in the MouseUp, where you store the coordinates and call Invalidate on your canvas control and draw in the Paint event of your canvas using its e.Graphics … Read more

Drawing Multiple Lines in D3.js

Yes. First I would restructure your data for easier iteration, like this: var series = [ [{time: 1, value: 2}, {time: 2, value: 4}, {time: 3, value: 8}], [{time: 1, value: 5}, {time: 2, value: 9}, {time: 3, value: 12}], [{time: 1, value: 3}, {time: 2, value: 2}, {time: 3, value: 2}], [{time: 1, value: … Read more

How to place multiple evenly-spaced arrowheads along an SVG line?

Based on a clarification of the question, here’s an implementation of creating intermediary points along a <polyline> element such that the marker-mid=”url(#arrowhead)” attribute will work. See below that for an introduction to markers and arrowheads. Demo: http://jsfiddle.net/Zv57N/ midMarkers(document.querySelector(‘polyline’),6); // Given a polygon/polyline, create intermediary points along the // “straightaways” spaced no closer than `spacing` distance … Read more