1[cases.bench_superblocks_found]
2# support benchmarking with files
3defines.N = [0, 1024]
4defines.FILE_SIZE = 8
5defines.CHUNK_SIZE = 8
6code = '''
7    lfs_t lfs;
8    lfs_format(&lfs, cfg) => 0;
9
10    // create files?
11    lfs_mount(&lfs, cfg) => 0;
12    char name[256];
13    uint8_t buffer[CHUNK_SIZE];
14    for (lfs_size_t i = 0; i < N; i++) {
15        sprintf(name, "file%08x", i);
16        lfs_file_t file;
17        lfs_file_open(&lfs, &file, name,
18                LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
19
20        for (lfs_size_t j = 0; j < FILE_SIZE; j += CHUNK_SIZE) {
21            for (lfs_size_t k = 0; k < CHUNK_SIZE; k++) {
22                buffer[k] = i+j+k;
23            }
24            lfs_file_write(&lfs, &file, buffer, CHUNK_SIZE) => CHUNK_SIZE;
25        }
26
27        lfs_file_close(&lfs, &file) => 0;
28    }
29    lfs_unmount(&lfs) => 0;
30
31    BENCH_START();
32    lfs_mount(&lfs, cfg) => 0;
33    BENCH_STOP();
34
35    lfs_unmount(&lfs) => 0;
36'''
37
38[cases.bench_superblocks_missing]
39code = '''
40    lfs_t lfs;
41
42    BENCH_START();
43    int err = lfs_mount(&lfs, cfg);
44    assert(err != 0);
45    BENCH_STOP();
46'''
47
48[cases.bench_superblocks_format]
49code = '''
50    lfs_t lfs;
51
52    BENCH_START();
53    lfs_format(&lfs, cfg) => 0;
54    BENCH_STOP();
55'''
56
57