-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Creating the memory usage (in bytes) quantifying function #6
Comments
For additional details, check this thread: #6
Done with the functionality, a test run: > asymptoticMemoryUsage(cDPA(rpois(data.sizes,10), rep(1,length(rpois(data.sizes,10))), 3L), data.sizes = 10^seq(1, 4, by = 0.5))
Memory usage Data sizes
1 6256 10.00000
2 9416 31.62278
3 20032 100.00000
4 51136 316.22777
5 149632 1000.00000
6 460960 3162.27766
7 1445632 10000.00000 Since it only gives one memory size value for each data size, it would be sensible to allocate more mid-range values in the sequence, and setting Here's a subsequent test for the parameter > asymptoticMemoryUsage(cDPA(rpois(data.sizes,10), rep(1,length(rpois(data.sizes,10))), 3L), data.sizes = 10^seq(1, 5, by = 0.1))
Memory usage Data sizes
1 6256 10.00000
2 6832 12.58925
3 7200 15.84893
4 7880 19.95262
5 8648 25.11886
6 9416 31.62278
7 11272 39.81072
8 12832 50.11872
9 14728 63.09573
10 17032 79.43282
11 20032 100.00000
12 23656 125.89254
13 28384 158.48932
14 34312 199.52623
15 41800 251.18864
16 51136 316.22777
17 62944 398.10717
18 77800 501.18723
19 96352 630.95734
20 119968 794.32823
21 149632 1000.00000
22 186784 1258.92541
23 233728 1584.89319
24 292936 1995.26231
25 367240 2511.88643
26 460960 3162.27766
27 578920 3981.07171
28 727240 5011.87234
29 914152 6309.57344
30 1149448 7943.28235 It stops further computation after a memory size value exceeds the default value which is 1MB or 10^6 bytes, (the 30th value above exceeds the hardcoded limit : 1,149,448 > 1,000,000) +In contrast, it runs faster as compared to Edit: PR merged. Branch : Memtest |
Can you provide some expected complexity cases for memory complexity testing? (i.e. functions with expected/known memory complexity) |
allocate a vector of size N -> O(N) |
Thanks! I'll test them and let you know the results here |
The first three are working fine, but when I test |
I also read about an O(NlogN) disk space case for |
good point. what is the squareroot complexity for? Do you have any examples of real algorithms with that time/memory complexity? (I dont know of any) |
ah okay, thanks!
No I don't, and I can't think of a use-case either, unless I explicitly make a function which runs with squareroot complexity |
Started with the memory metrics (usage in bytes) quantifier, with a few adaptations in relation to the timings quantifier. Keynote:
bench
essentially computes benchmarks for both time and memory allocations for an R expression, so it won't return an applicable1 data.frame for memory metrics specifically, as microbenchmark did in contrast for time results. (it only had timings plus it didn't result in a singular output value)The equivalent to extracting memory is by using
bench::bench_memory
or by retrievingmem_alloc
frombench::mark
. Both ways would end up with a singular value for whatsoever input (an expression) supplied, which we can extract by selecting the memory allocation column, example:mem_alloc
is one among the two types of data thatbench_memory
returns:However, the second
memory
column just shows the allocations per step additionally (it is not use-able1 as a data.frame) and provides nothing extra, with the total allocated value in bytes (see last row below) being supplied tomem_alloc
:Ideally,
mem_alloc
is the only value we will be requiring after all.However, this does raise a question, as you saw in the results for
cDPA
above,mem_alloc
returns the sizes in kilobytes (KB) or for a larger value it would return in equivalent conversions such as in MB, but the memory allocations are calculated in bytes, so are the values (KB, MB) directly comparable in bytes? - yes, they are. Here's a short test which proves that:This is preferred, since otherwise we have to resort to convert it back into bytes as per "KB/MB" string-parsing or with regex and we would require it to be in bytes strictly since we will compare it with
max.bytes
(similar tomax.seconds
), the max. memory allocation limit per iteration.But then this means that there must be some implicit conversion - which sparks the realization for the subsequent error I recieved.2
Following the established logic from
asymptoticTimings
, making required changes and extracting that single allocated memory size value per iteration - we would expect it to be fine:but it throws:
which didn't make much sense at the first glance, but then I eventually got to understand the meaning of that error message.2
Yup, its the conversion from higher memory size units (MBs/KBs) to bytes.
I made small test functions for different cases as to know what could be the reason for that, and this is the one which reproduced the same error:
This error makes sense now, as we are collecting the
mem_alloc
value and ourdata.size
(N here) in adata.frame
, which makes the same aforementioned conversion (dividing total bytes by the byte unit value, such as 1000 for KB, and then rounding-off, as mentioned in the error message) rule apply to all the parameters within, i.e. it would work fine formem_alloc
objects which need a conversion, but not fordata.size
which does not require the same. (and hence invalid 'second' argument)To verify, just returning the allocated memory size value (without the data frame) works:
which means I'll need to devise something else instead of collecting it directly in a data frame along with the data size for each iteration.
Branch : Memtest
Objectives: Add memory usage quantifier, complexity classifier and plotter function with corresponding documentation & unit-tests.
The text was updated successfully, but these errors were encountered: