Part 1
요약·해설
Separate Chaining, Open Addressing/Linear Probe와 C++ unordered_map wrapper 선택법을 설명합니다.
Operations
Insert · Replace · Remove
Backends
SC · OA/LP · C++
Target
native_sim
Part 2
접을 수 있는 영어 원문 전체
영어 원문 전체 펼치기
원문 SHA-256
C65B39F98B56F82DC246498E9C189C313EC02C163F4D875885A2180E76352500
.. zephyr:code-sample:: system_hashmap
:name: System hashmap
:relevant-api: hashmap_apis
Insert, replace, and remove entries in a hashmap.
Overview
********
This is a simple example that repeatedly:
* inserts up to ``CONFIG_TEST_LIB_HASH_MAP_MAX_ENTRIES``
* replaces up to the same number that were previously inserted
* removes all previously inserted keys
Building
********
This application can be built on :ref:`native_sim <native_sim>` as follows:
.. zephyr-app-commands::
:zephyr-app: samples/basic/hash_map
:host-os: unix
:board: native_sim
:goals: build
:compact:
To build for another board, change "native_sim" above to that board's name.
Additionally, it is possible to use one of the other Hashmap implementations by specifying
* ``CONFIG_SYS_HASH_MAP_CHOICE_SC=y`` (Separate Chaining)
* ``CONFIG_SYS_HASH_MAP_CHOICE_OA_LP=y`` (Open Addressing / Linear Probe)
* ``CONFIG_SYS_HASH_MAP_CHOICE_CXX=y`` (C Wrapper around the C++ ``std::unordered_map``)
To stress the Hashmap implementation, adjust ``CONFIG_TEST_LIB_HASH_MAP_MAX_ENTRIES``.
Running
*******
Run ``build/zephyr/zephyr.exe``
Sample Output
*************
.. code-block:: console
System Hashmap sample
[00:00:11.000,000] <inf> hashmap_sample: n_insert: 118200 n_remove: 295500 n_replace: 329061 n_miss: 0 n_error: 0 max_size: 118200
[00:00:11.010,000] <inf> hashmap_sample: success
Part 3
한국어 전문 번역
개요
다음 작업을 반복하는 간단한 example입니다.
CONFIG_TEST_LIB_HASH_MAP_MAX_ENTRIES개까지 entry 삽입- 앞서 삽입한 것과 같은 수까지 entry 교체
- 앞서 삽입한 모든 key 제거
Build
다음과 같이 native_sim용 application을 build합니다.
west build -b native_sim samples/basic/hash_map
다른 board용으로 build하려면 native_sim을 해당 board 이름으로 바꾸십시오.
다음 option 가운데 하나를 지정해 다른 Hashmap 구현을 사용할 수도 있습니다.
CONFIG_SYS_HASH_MAP_CHOICE_SC=y: Separate ChainingCONFIG_SYS_HASH_MAP_CHOICE_OA_LP=y: Open Addressing/Linear ProbeCONFIG_SYS_HASH_MAP_CHOICE_CXX=y: C++std::unordered_map의 C wrapper
Hashmap 구현에 stress를 주려면 CONFIG_TEST_LIB_HASH_MAP_MAX_ENTRIES를 조정합니다.
실행
build/zephyr/zephyr.exe를 실행합니다.
Sample 출력
System Hashmap sample
[00:00:11.000,000] <inf> hashmap_sample: n_insert: 118200 n_remove: 295500 n_replace: 329061 n_miss: 0 n_error: 0 max_size: 118200
[00:00:11.010,000] <inf> hashmap_sample: success
Source
출처
영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.