๋น๊ต - Count() > 0, Any(), Count > 0
Count() > 0 on a List with 1,000,000 elements
Any() on the same list
Count > 0 using the property
๊ฒฐ๊ณผ
| Method | Mean | Allocated |
|----------------|-----------|-----------|
| CountMethod | 20.521 us | 0 B |
| AnyMethod | 0.989 us | 0 B |
| PropertyAccess | 0.045 us | 0 B |
๊ธ : Boost Your C# Code: Why Any() is Faster Than Count() > 0 for Performance
์ ์ : Sukhpinder Singh
1 Like
jrchs
April 25, 2025, 12:05am
2
Any()๊ฐ Count()๋ณด๋ค ํจ์จ์ ์ด๊ธดํ๋ฐ Npgsql.EntityFrameworkCore.PostgreSQL์์๋ ์ง์๋์ง ์์ต๋๋ค.
1 Like
IQueryable.Any() ์ ๊ฐ์ ๊ฐ๋จํ ์ฟผ๋ฆฌ๊ฐ ์ง์๋์ง ์์ ๋ฆฌ๊ฐ ์์ํ
๋ฐ์.
1 Like
jrchs
April 25, 2025, 1:31am
4
Npgsql.EntityFrameworkCore.PostgreSQL 5.x ๋ฒ์ ์ฌ์ฉ์ค์ธ๋ฐ Any()๋ฅผ ์ฌ์ฉํ๋ฉด could not be translated๋ผ๊ณ ์ค๋ฅ๋ฉ๋๋ค. ๊ทธ๋์ ์ด์ฉ์ ์์ด Count()๋ฅผ ์ฌ์ฉํ๊ณ ์์ต๋๋ค.
1 Like
์ง๊ธ ๋ฒ์ ์ด 10์ธ๋ฐ, ๋๋ฌด ์ค๋๋ ๋ฒ์ ์ ์ฌ์ฉํ๊ณ ๊ณ์ ๋ฏ ํฉ๋๋ค.
ํ์ฌ๋ ์๋ฌด๋ฐ ๋ฌธ์ ์์ด ๋ฉ๋๋ค.
2 Likes