Skip to content
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

Design cache tests #2

Open
chungphb opened this issue Apr 23, 2021 · 2 comments
Open

Design cache tests #2

chungphb opened this issue Apr 23, 2021 · 2 comments
Labels
cache Related to cache test Related to test

Comments

@chungphb
Copy link
Owner

No description provided.

@chungphb
Copy link
Owner Author

chungphb commented Apr 23, 2021

Test put

Consecutive data

If n_unique_items <= capacity

  • Example:
    • Cache: capacity = 4
    • Access pattern: 1 2 3 (n_unique_items = 3)
    • Cache items / Cache history: {1}/{} -> {2 1}/{} -> {3 2 1}/{}
  • Requirements:
    • Cache items = REVERSE({Access pattern})
    • Cache history = {}

If n_unique_items > capacity

  • Example:
    • Cache: capacity = 4
    • Access pattern: 1 2 3 4 5 6 (n_unique_items = 6)
    • Cache items / Cache history: {1}/{} -> {2 1}/{} -> {3 2 1}/{} -> {4 3 2 1}/{} -> {5 4 3 2}/{1} -> {6 5 4 3}/{2 1}
  • Requirements:
    • Cache items = GET_FIRST_N_ITEMS(REVERSE({Access pattern)), capacity)
    • Cache history != REVERSE(GET_FIRST_N_ITEMS({Access pattern}, n_unique_items - capacity))

Random data

If n_unique_items <= capacity

  • Example:
    • Cache: capacity = 4
    • Access pattern: 1 3 2 4 4 2 1 3 (n_unique_items = 4)
    • Cache items / Cache history: {1}/{} -> {3 1}/{} -> {2 3 1}/{} -> {4 2 3 1}/{} -> {4 2 3 1}/{} -> {2 4 3 1}/{} -> {1 2 4 3}/{} -> {3 1 2 4}/{}
  • Requirements:
    • Cache items = REMOVE_DUPLICATION(REVERSE({Access pattern}))
    • Cache history = {}

If n_unique_items > capacity

  • Example:
    • Cache: capacity = 3
    • Access pattern: 1 3 2 4 4 2 1 3 (n_unique_items = 4)
    • Cache items / Cache history: {1}/{} -> {3 1}/{} -> {2 3 1}/{} -> {4 2 3}/{1} -> {4 2 3}/{1} -> {2 4 3}/{1} -> {1 2 4}/{3 1} -> {3 1 2}/{4 3 1}
  • Requirements:
    • Cache items = GET_FIRST_N_ITEMS(REMOVE_DUPLICATION(REVERSE({Access pattern)), capacity)
    • Cache history != {} [TODO]

@chungphb
Copy link
Owner Author

chungphb commented Apr 24, 2021

Test get

  • There is no need to differentiate consecutive access pattern and random access pattern because for the most part, n_unique_items on the "get" access pattern will be less than or equal to the cache size and the requirements for these two cases are fairly similar.
  • For items not on the cache, we can check them separately to avoid complication.

If n_unique_items = size

  • Example:
    • Cache (after putting): 1 2 3 4 (size = 4)
    • Access pattern: 1 3 2 4 2 3 (n_unique_items = 4)
    • Cache items: {1 2 3 4} -> {3 1 2 4} -> {2 3 1 4} -> {4 2 3 1} -> {2 4 3 1} -> {3 2 4 1}
  • Requirements:
    • Cache items = REMOVE_DUPLICATION(REVERSE({Access pattern}))

If n_unique_items < size

  • Example:
    • Cache (after putting): 1 2 3 4 (size = 4)
    • Access pattern: 1 3 1 1 3 (n_unique_items = 2)
    • Cache items: {1 2 3 4} -> {3 1 2 4} -> {1 3 2 4} -> {1 3 2 4} -> {3 1 2 4}
  • Requirements:
    • GET_FIRST_N_ITEMS({Cache items}, n_unique_items) = REMOVE_DUPLICATION(REVERSE({Access pattern}))
    • This could also be applied for the first scenario.

@chungphb chungphb changed the title [cache_test] Design cache tests Design cache tests May 3, 2021
@chungphb chungphb added cache Related to cache test Related to test labels May 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cache Related to cache test Related to test
Projects
None yet
Development

No branches or pull requests

1 participant