Skip to content
Browse files
time: in Format give buffer an initial capacity
I have a small web server that simply sets several cookies
along with an expires header, and then returns.  In the
cpuprofile for a 200k request benchmark, time.Time.Format()
was showing up as 8.3% of cpu usage.  Giving the buffer an
inital capacity to avoid reallocs on append drops it down to

R=golang-dev, r
  • Loading branch information
bpowers authored and robpike committed Apr 7, 2012
1 parent f273487 commit c9529e02c1454de4e88f402df666cdccec25a744
Showing 1 changed file with 1 addition and 1 deletion.
@@ -367,7 +367,7 @@ func (t Time) Format(layout string) string {
hour int = -1
min int
sec int
b buffer
b buffer = make([]byte, 0, len(layout))
// Each iteration generates one std value.
for {

0 comments on commit c9529e0

Please sign in to comment.