| 1 | import os |
| 2 | |
| 3 | @[direct_array_access] |
| 4 | fn test_big_int_array() { |
| 5 | dump(sizeof(isize)) |
| 6 | mut maxn := 500_000_000 // try allocating ~2GB worth of integers on 32bit platforms |
| 7 | if sizeof(isize) > 4 { |
| 8 | maxn = 1_000_000_000 // 1 billion integers, when each is 4 bytes => require ~4GB |
| 9 | } |
| 10 | // NB: this test requires RAM that many people do not have, so only run it in full, when VTEST_BIGMEM is 1 |
| 11 | vtest_bigmem := os.getenv('VTEST_BIGMEM').int() |
| 12 | if vtest_bigmem == 0 { |
| 13 | maxn = 10_000_000 |
| 14 | } |
| 15 | dump(maxn) |
| 16 | mut data := []int{len: maxn} |
| 17 | |
| 18 | // ensure that all of the elements are written at least once, to prevent the OS from cheating: |
| 19 | for i in 0 .. maxn { |
| 20 | data[i] = i |
| 21 | } |
| 22 | assert data[0] == 0 |
| 23 | assert data[maxn - 1] == maxn - 1 |
| 24 | dump(data#[0..10]) |
| 25 | dump(data#[-10..]) |
| 26 | } |
| 27 | |