Using std.net.curl to stream data

2015-01-28 Thread Trollgeir via Digitalmars-d-learn

I'm having some trouble trying to stream data to my plot.ly graph:
https://plot.ly/62/~Trollgeir/

The API:  https://plot.ly/streaming/

I am able to post messages that get recorded into the stream 
live, although right after curl uploads it, it just seems to wait 
for a response it's not getting, and eventually timeouts. Does 
anyone have any advice?


auto client = HTTP("stream.plot.ly");
client.addRequestHeader("plotly-streamtoken","e8bg6omat6");
client.verbose = true;

string msg = "{ \"x\": 500, \"y\": 500 } \n";
client.postData(msg);
client.perform; 


Re: core.bitop.bt not faster than & ?

2014-12-17 Thread Trollgeir via Digitalmars-d-learn
On Wednesday, 17 December 2014 at 14:58:13 UTC, Adam D. Ruppe 
wrote:

On Wednesday, 17 December 2014 at 14:12:16 UTC, Trollgeir wrote:
I'd expect the bt function to be up to 32 times faster as I 
thought it only compared two bits, and not the entire length 
of bits in the uint.


The processor doesn't work in terms of bits like that - it 
still needs to look at the whole integer. In fact, according to 
my (OLD) asm reference, the bt instruction is slower than the 
and instruction at the cpu level.


I think it has to do a wee bit more work, translating the 16 
into a mask then moving the result into the flag... then moving 
the flag back into a register to return the value. (That last 
step could probably be skipped if you do an if() on it and the 
compiler optimizes the branch, and the first step might be 
skipped too if it is a constant, since the compiler can rewrite 
the instruction. So given that, I'd expect what you saw: no 
difference when they are optimized to the same thing or when 
the CPU's stars align right, and & a bit faster when bt isn't 
optimized)


bt() and friends are special instructions for specialized use 
cases. Probably useful for threading and stuff.



Thanks for the explanation, I suspected it might work something 
like that.


For my implementation - I have bits shifting to the right every 
update, and I want to check if it has reached certain markers. 
Hence, I felt it was really inefficient to check every single bit 
in the uint when I was only interested in some specific ones. Is 
an alternative (optimized) version of bt even possible?


core.bitop.bt not faster than & ?

2014-12-17 Thread Trollgeir via Digitalmars-d-learn
I've been doing some benchmarking the bt function 
(http://dlang.org/phobos/core_bitop.html) up against a regular 
bit & -operator, and I'm a bit confused over the timings.


I'd expect the bt function to be up to 32 times faster as I 
thought it only compared two bits, and not the entire length of 
bits in the uint. The results I got indicated that there were no 
difference between that and just a regular & condition. In most 
cases, the & was actually a tad bit faster!


Ex.

bt(&element, 16) vs (element & 0b1000)

Can anyone confirm this?


I used a simple std.datetime benchmark template iterating over a 
static array[10], trying both random values for each entry 
and fixed ones.





std.bitmanip - bitshift?

2014-12-12 Thread Trollgeir via Digitalmars-d-learn

http://dlang.org/phobos/std_bitmanip.html

Does anyone know how to bit-shift a BitArray?

I'm trying to make spikes in a neural network travel along the
bits as they have various lengths.