this post was submitted on 16 Jun 2023
103 points (100.0% liked)

Programmer Humor

19512 readers
394 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 1 year ago
MODERATORS
 
top 14 comments
sorted by: hot top controversial new old
[–] argv_minus_one@beehaw.org 7 points 1 year ago* (last edited 1 year ago) (2 children)

Finding clothes on a chair isn't constant-time. You have to search through the heap of clothes to find the item you want. It has the same time complexity as searching through the closet; it's only fast because n is small.

[–] IronDonkey@lemmy.world 3 points 1 year ago* (last edited 1 year ago)

This assumes you're looking for a particular item of clothing. It's true that the clothes cache is not optimized for that.

However, if you are instead looking for a shirt, a pair of pants, and/or so on, without regards to which specific shirt, and if the cache is randomly sorted and the distribution of all such items is roughly equal, then it becomes O(1) - regardless of the size of the cache, you'll get what you want within 4 or 5 checks. Plus, you typically want one of each of the types of item, and you'll get all of them within those same 4 or 5 checks.

Bonus: the checks can be parallelized by using a "wide" cache that enables multiple items to be checked at once. This is why I use a short and wide clean clothes basket and a tall and skinny dirty clothes basket.

[–] omenmis@beehaw.org 2 points 1 year ago (1 children)

It takes 2 pause cycles, that's essentially O(1) compared to a cache miss.

[–] jcg@halubilo.social 5 points 1 year ago* (last edited 1 year ago)

You could implement in-closet indexing instead to make the cache misses hurt less, trading off some extra insertion time but needing less memory for the cache which is much more expensive cost wise. At this point you're storing almost your whole DB in the cache and your room's a mess.

[–] Tempiz@sh.itjust.works 4 points 1 year ago

Upgraded cache = bigger clothes pile.

[–] SpezCanLigmaBalls@lemmy.world 3 points 1 year ago (1 children)

I’ve been subscribed to this subreddit for years and so much shit is way over my head lol

[–] Deebster@lemmyrs.org 1 points 1 year ago (1 children)

I'm really confused by this - is this a bot reposting replies that don't work because the context has changed or is this some super-meta content that I'm whooshing on.

[–] SpezCanLigmaBalls@lemmy.world 3 points 1 year ago

No I’m just stupid

[–] Kettlepants@lemm.ee 3 points 1 year ago

I like this logic.

[–] MartianInAHumansBody@lemmy.ca 3 points 1 year ago

I feel better now about my bad habits

[–] TeddE@lemmy.world 3 points 1 year ago

BRB, getting new clothes from the datastore

[–] darcy@lemmy.blahaj.zone 3 points 1 year ago

I just expand my L1 cache to half my wardrobe hehe

[–] rektifier@sh.itjust.works 1 points 1 year ago

I store my clothes in a stack, and I usually wear the same few pieces until the season changes.

[–] Valmond@lemmy.mindoki.com 1 points 11 months ago

O(k) time to be pedantic, where k is the number of layers.

load more comments
view more: next ›