Simon Gust
Member
I have some questions regarding data structures.
I know that they are altered arrays with various features in them making them suitable for different situations.
In my situation, I want to read and write a lot of data in a single draw.
My idea was to use a ds_stack to push and pop data super fast.
But I was disappointed, ds_list is somehow faster than a ds_stack? How come, when I have to feed an offset that reading is still faster in a ds_list. Am I doing something wrong?
queue: infinity ms
stack 330 ms
list: 255 ms
array 30 ms
This led me to believe that arrays must then be even faster than lists (which is true). But to me it doesn't feel like that is the task an array or list should take.
My plight: Is there a faster way to push and pop data than an array?
I know that they are altered arrays with various features in them making them suitable for different situations.
In my situation, I want to read and write a lot of data in a single draw.
My idea was to use a ds_stack to push and pop data super fast.
But I was disappointed, ds_list is somehow faster than a ds_stack? How come, when I have to feed an offset that reading is still faster in a ds_list. Am I doing something wrong?
Code:
repeat (120000) {
//ds_queue_enqueue(queue, random(100));
ds_stack_push(stack, random(100));
// vs
ds_list_add(list, random(100));
//array[i++] = random(100);
}
buffer_seek(buffer, 0, 0);
// reading
var i = 0;
repeat (120000) {
//var r = ds_queue_dequeue(queue);
var r = ds_stack_pop(stack);
// vs
var r = ds_list_find_value(list, i++);
//var r = array[i++];
}
stack 330 ms
list: 255 ms
array 30 ms
This led me to believe that arrays must then be even faster than lists (which is true). But to me it doesn't feel like that is the task an array or list should take.
My plight: Is there a faster way to push and pop data than an array?