# [c++] 빠르게, 더 빠르게 (성능 튜닝)

> Clean Markdown view of GeekNews topic #12162. Use the original source for factual precision when an external source URL is present.

## Metadata

- GeekNews HTML: [https://news.hada.io/topic?id=12162](https://news.hada.io/topic?id=12162)
- GeekNews Markdown: [https://news.hada.io/topic/12162.md](https://news.hada.io/topic/12162.md)
- Type: news
- Author: [frogred8](https://news.hada.io/@frogred8)
- Published: 2023-12-04T11:43:30+09:00
- Updated: 2023-12-04T11:43:30+09:00
- Original source: [frogred8.github.io](https://frogred8.github.io/docs/030_fast_and_faster/)
- Points: 10
- Comments: 1

## Topic Body

- Matt Godbolt의 유튜브 세션을 글로 풀어서 정리한 내용  
  - https://www.youtube.com/watch?v=fV6qYho-XVs  
- 숫자, 문자를 받아서 합성하는 단순한 기능의 최적화  
- perf 툴로 분석하여 단계별 최적화를 진행  
  1. stringstream (550ns)  
  2. sprintf (220ns)  
  3. custom formatter (20ns)  
  4. custom formatter + lookup table + @ (13ns)  
- 최초보다 42배 빨라진 최종 코드  
  - https://godbolt.org/z/3befMz74j  
- 결론: 최적화 할 때에는 직관을 따르지 말고, 면밀한 성능 측정이 우선되어야 한다

## Comments



### Comment 21087

- Author: q8840
- Created: 2023-12-04T13:20:46+09:00
- Points: 2

성급한 최적화는 만악의 근원이다  
  
최적화도 좋지만 블로그 글을 보고 무조건적인 불필요한 최적화를 할 사람들을 위해 경고해두면 좋을것같네요..
