实验目的:初步评估写入速度
硬件平台:F407+SPIFlash
代码如下:
for (count = 1; count < 30000; count++) {
snprintf(key,128,"%010d", count);
snprintf(val,128,"2024-06-07 14:39 %8d", count);
fdb_kv_set(kvdb, key, val);
FDB_INFO("insert [%d]", count);
{ /* GET the KV value */
char *return_value, temp_data2[30] = { 0 };
/* Get the "temp" KV value.
* NOTE: The return value saved in fdb_kv_get's buffer. Please copy away as soon as possible.
*/
return_value = fdb_kv_get(kvdb, key);
/* the return value is NULL when get the value failed */
if (return_value != NULL) {
strncpy(temp_data2, return_value, sizeof(temp_data2));
FDB_INFO("get the value is: %s\n", temp_data2);
}
}
}
在只有几条数据时,写入也需要40ms
[18:41:39.933]收←◆S
[18:41:40.064]收←◆ystem Clock information
SYSCLK_Frequency = 168000000
HCLK_Frequency = 168000000
PCLK1_Frequency = 42000000
PCLK2_Frequency = 84000000
[SFUD]Find a Winbond W25Q128JV flash chip. Size is 8388608 bytes.
[SFUD](..\sfud\src\sfud.c:840) Flash device reset success.
[SFUD]norflash0 flash device is initialize success.
[D/FAL] (fal_flash_init:47) Flash device | norflash0 | addr: 0x00000000 | len: 0x00800000 | blk_size: 0x00001000 |initialized finish.
[32;22m[I/FAL] ==================== FAL partition table ====================[0m
[32;22m[I/FAL] | name | flash_dev | offset | length |[0m
[32;22m[I/FAL] -------------------------------------------------------------[0m
[32;22m[I/FAL] | fdb_tsdb1 | norflash0 | 0x00000000 | 0x00100000 |[0m
[32;22m[I/FAL] | fdb_kvdb1 | norflash0 | 0x00100000 | 0x00100000 |[0m
[32;22m[I/FAL] =============================================================[0m
[32;22m[I/FAL] Flash Abstraction Layer (V0.5.99) initialize success.[0m
[FlashDB][kv][env][fdb_kvdb1] (..\..\..\src\fdb_kvdb.c:1777) The oldest addr is @0x00000000
[FlashDB][kv][env][fdb_kvdb1] (..\..\..\src\fdb_kvdb.c:1793) KVDB size is 1048576 bytes.
[18:41:40.144]收←◆[FlashDB] FlashDB V2.1.0 is initialize success.
[FlashDB] You can get the latest version on https://github.com/armink/FlashDB .
[FlashDB][sample][kvdb][basic] ==================== kvdb_basic_sample ====================
[FlashDB][sample][kvdb][basic] get the 'boot_count' value is 1
[18:41:40.206]收←◆[FlashDB][sample][kvdb][basic] set the 'boot_count' value to 2
[FlashDB][sample][kvdb][basic] ===========================================================
[FlashDB][sample][kvdb][string] ==================== kvdb_type_string_sample ====================
[18:41:40.257]收←◆[FlashDB][sample][kvdb][string] create the 'temp' string KV, value is: 36C
[FlashDB][sample][kvdb][string] get the 'temp' value is: 36C
[FlashDB][sample][kvdb][string]
[18:41:40.297]收←◆set 'temp' value to 38C
[FlashDB][sample][kvdb][string] delete the 'temp' finish
[FlashDB][sample][kvdb][string] ===========================================================
[FlashDB][sample][kvdb][blob] ==================== kvdb_type_blob_sample ====================
[18:41:40.350]收←◆[FlashDB][sample][kvdb][blob] create the 'temp' blob KV, value is: 36
[FlashDB][sample][kvdb][blob] get the 'temp' value is: 36
[FlashDB][sample][kvdb][blob] set 'temp'
[18:41:40.372]收←◆value to 38
[FlashDB][sample][kvdb][blob] delete the 'temp' finish
[FlashDB][sample][kvdb][blob] insert [1][FlashDB][sample][kvdb][blob] get the value is: 2024-06-07 14:39 1
[FlashDB][sample][kvdb][bl
[18:41:40.416]收←◆ob] insert [2][FlashDB][sample][kvdb][blob] get the value is: 2024-06-07 14:39 2
[FlashDB][sample][kvdb][blob] insert [3][FlashDB][sample][kvdb][blob] get the value is: 2024-06-07 14:39 3
[18:41:40.460]收←◆[FlashDB][sample][kvdb][blob] insert [4][FlashDB][sample][kvdb][blob] get the value is: 2024-06-07 14:39 4
[FlashDB][sample][kvdb][blob] insert [5][FlashDB][sample][kvdb][blob] get the value is: 2024-06-07 14:39 5
[18:41:40.508]收←◆[FlashDB][sample][kvdb][blob] insert [6][FlashDB][sample][kvdb][blob] get the value is: 2024-06-07 14:39 6
[FlashDB][sample][kvdb][blob] insert [7][FlashDB][sample][kvdb][blob] get the value is: 2024-06-07 14:39 7
[18:41:40.555]收←◆[FlashDB][sample][kvdb][blob] insert [8][FlashDB][sample][kvdb][blob] get the value is: 2024-06-07 14:39 8
[FlashDB][sample][kvdb][blob] insert [9][FlashDB][sample][kvdb][blob] get the value is: 2024-06-07 14:39 9
[18:41:40.605]收←◆[FlashDB][sample][kvdb][blob] insert [10][FlashDB][sample][kvdb][blob] get the value is: 2024-06-07 14:39 10
在读写5781条处,用时2.3秒。
在读写9301条处,用时3.686秒。
3个小时写入约3587条数据(9367-5780)。