timing vs size of byte string

Discussion about LiveCode Global Jam events and activities

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

Post Reply
DarScott
Posts: 225
Joined: Fri Jul 28, 2006 12:23 am
Location: Albuquerque
Contact:

timing vs size of byte string

Post by DarScott » Sat May 24, 2014 6:31 am

The most important chunk operations might be characters. However, for some of what I do, bytes are important. Here are some characteristics of how long it takes to do some things regarding a single byte of a long byte string. I'll start out with deleting a byte at an end.

For a million bytes it takes about 0.4 ms to delete the last byte, but sometimes it can be over 1.5 ms. To delete the first byte of a million byte string takes about 0.5 ms on my computer, but it can take 2 ms.
Attachments
time to delete last byte.png
time to delete 1st byte.png

DarScott
Posts: 225
Joined: Fri Jul 28, 2006 12:23 am
Location: Albuquerque
Contact:

Re: timing vs size of byte string

Post by DarScott » Sat May 24, 2014 6:35 am

The time to get a byte is similar.
Attachments
time to get a mid byte.png
time to get 1st byte.png

DarScott
Posts: 225
Joined: Fri Jul 28, 2006 12:23 am
Location: Albuquerque
Contact:

Re: timing vs size of byte string

Post by DarScott » Sat May 24, 2014 6:43 am

The time to add a byte to the end of a byte string is very small and constant, about 0.0003 ms on my computer (300 ns).

EDIT: And the time to add a byte to the front is about 300 ns plus 60 ns for every 1000 bytes. So, for large strings there is a slight advantage to adding bytes to the back.
Last edited by DarScott on Sat May 24, 2014 8:29 pm, edited 1 time in total.

DarScott
Posts: 225
Joined: Fri Jul 28, 2006 12:23 am
Location: Albuquerque
Contact:

Re: timing vs size of byte string

Post by DarScott » Sat May 24, 2014 7:04 am

Getting the number of bytes of a byte string also depends on the length. (I think it is remembered though.) Something interesting is going on near a million bytes. Just under that, though, getting the length seems to take 150 microseconds. I have seen it take longer though, and in one test it seems to take around 350 microseconds.

EDIT: In subsequent runs, this has the same pattern as the others, only half the values. I don't know why this chart doesn't have the higher scatter.

I wonder if most operations do two 'the number of bytes' and it is the root of all slowness.
Attachments
time to get num of bytes.png
Last edited by DarScott on Sun May 25, 2014 10:05 pm, edited 1 time in total.

DarScott
Posts: 225
Joined: Fri Jul 28, 2006 12:23 am
Location: Albuquerque
Contact:

Re: timing vs size of byte string

Post by DarScott » Sat May 24, 2014 7:05 am

These tests were made by adding bytes to the end of a byte string and doing tests every 1000.

DarScott
Posts: 225
Joined: Fri Jul 28, 2006 12:23 am
Location: Albuquerque
Contact:

Re: timing vs size of byte string

Post by DarScott » Sat May 24, 2014 8:33 pm

The loop time for touching every byte with 'repeat for each byte' is constant and small, about 260 ns on my machine. The time to touch all the bytes in a byte string with the number of bytes = n is 260n + 70000 in ns. That is about 70 microseconds plus a quarter of a microsecond for each byte.

DarScott
Posts: 225
Joined: Fri Jul 28, 2006 12:23 am
Location: Albuquerque
Contact:

Re: timing vs size of byte string

Post by DarScott » Sun May 25, 2014 6:18 am

The time to double the length of a string as in 'get s & s' is 2 microseconds plus a microsecond for every 3000 bytes of s. A million byte string takes about 340 microseconds to double.

Post Reply

Return to “LiveCode Global Jam”