# peach vs each

**URL:** <https://forum.kx.com/t/peach-vs-each/8082>\
**Category:** Community Support\
**Tags:** kdb-and-q\
**Created:** [January 3, 2013, 12:37pm UTC](https://forum.kx.com/t/peach-vs-each/8082 "2013-01-03T12:37:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sean11](https://avatars.discourse-cdn.com/v4/letter/s/54ee81/32.png) [@Sean11](https://forum.kx.com/u/Sean11)\
**Post date:** [January 3, 2013, 12:37pm UTC](https://forum.kx.com/t/peach-vs-each/8082/1 "2013-01-03T12:37:00Z")

</div>

Hello,  
I have 2 functions f1 and f2. Why is ‘peach’ slower than ‘each’ in f2?

q)\s

8i

q)f1:{do[100000;x+x]}

q)f2:{do[100000;x+2]}

q)\t f1 each til 8

218

q)\t f1 peach til 8

27

q)\t f2 each til 8

165

q)\t f2 peach til 8

307

(It seems having constants in the do loop makes ‘peach’ slower)

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Ryan\_Hamilton](https://avatars.discourse-cdn.com/v4/letter/r/439d5e/32.png) [@Ryan\_Hamilton](https://forum.kx.com/u/Ryan_Hamilton)\
**Post date:** [January 3, 2013, 2:35pm UTC](https://forum.kx.com/t/peach-vs-each/8082/2 "2013-01-03T14:35:00Z")

</div>

Hi,

On mine it works as expected. Perhaps some of your cores were busy doing  
other work. Try repeating it a few time while making sure nothing else  
is running.

q)q)f1:{do[100000;x+x]}  
q)q)f2:{do[100000;x+2]}  
q)\t f1 each til 8  
114  
q)\t f1 peach til 8  
45  
q)\t f2 each til 8  
148  
q)\t f2 peach til 8  
73  
q)\s  
8i  
q).z.k  
2012.11.13  
q).z.K  
3f

On 1/3/2013 12:37 PM, Jinming Shao wrote:  
\> Hello,  
\> I have 2 functions f1 and f2. Why is ‘peach’ slower than ‘each’ in f2?  
\>  
\> q)\s  
\> 8i  
\> q)f1:{do[100000;x+x]}  
\> q)f2:{do[100000;x+2]}  
\> q)\t f1 each til 8  
\> 218  
\> q)\t f1 peach til 8  
\> 27  
\> q)\t f2 each til 8  
\> 165  
\> q)\t f2 peach til 8  
\> 307  
\>  
\> (It seems having constants in the do loop makes ‘peach’ slower)  
\>  
\> Thanks in advance.  
\> –  
\> You received this message because you are subscribed to the Google  
\> Groups “Kdb+ Personal Developers” group.  
\> To post to this group, send email to [personal-kdbplus@googlegroups.com](mailto:personal-kdbplus@googlegroups.com).  
\> To unsubscribe from this group, send email to  
\> [personal-kdbplus+unsubscribe@googlegroups.com](mailto:personal-kdbplus+unsubscribe@googlegroups.com).  
\> For more options, visit this group at  
\> [http://groups.google.com/group/personal-kdbplus?hl=en](http://groups.google.com/group/personal-kdbplus?hl=en).

---

<div class="post-metadata">

**Author:** ![Sean11](https://avatars.discourse-cdn.com/v4/letter/s/54ee81/32.png) [@Sean11](https://forum.kx.com/u/Sean11)\
**Post date:** [January 3, 2013, 3:36pm UTC](https://forum.kx.com/t/peach-vs-each/8082/3 "2013-01-03T15:36:00Z")

</div>

I tried it several times, ‘peach’ is constantly slower than ‘each’ for f2.  
Noticed my version is older than yours:

q).z.k

2012.05.29

q).z.K

3f
