Post Reply 
What's wrong with your HEAD?
10-07-2018, 02:47 PM (This post was last modified: 10-07-2018 03:11 PM by John Keith.)
Post: #1
What's wrong with your HEAD?
Reading this post in the HHC 2018 Programming Contests thread reminded me that I had always thought of HEAD as being slow, so I decided to run some tests. HEAD is slightly faster than 1. GET (by about 1 millisecond) but both slow down significantly on large lists. The longer (and much less elegant!) sequence 1. 1. SUB EVAL is only slightly faster than HEAD on small lists, but note the timings on a list of 1000 items:

Code:

HEAD           22ms
1. GET         23ms
1. 1. SUB EVAL 3.1ms

This is shocking to me since HEAD is one of the fundamental list processing commands and one would expect it to be highly optimized. There are situations where 1. 1. SUB EVAL does not give the same result as HEAD (such as a list of programs), but I still can't see why HEAD is so much slower.

Edited to add that 2. OVER SIZE SUB is slower than TAIL (49ms vs 28ms on a list of 1000 integers). Curiouser and curiouser! I suspect that garbage collection is partially responsible for the slowness on large lists but I still don't know why HEAD is that much slower than SUB.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
What's wrong with your HEAD? - John Keith - 10-07-2018 02:47 PM
RE: What's wrong with your HEAD? - 3298 - 10-07-2018, 08:55 PM
RE: What's wrong with your HEAD? - pier4r - 10-07-2018, 09:19 PM
RE: What's wrong with your HEAD? - DavidM - 10-08-2018, 03:54 AM
RE: What's wrong with your HEAD? - 3298 - 10-08-2018, 10:06 AM
RE: What's wrong with your HEAD? - DavidM - 10-08-2018, 03:36 PM
RE: What's wrong with your HEAD? - pier4r - 10-08-2018, 05:24 PM
RE: What's wrong with your HEAD? - DavidM - 10-08-2018, 04:12 PM
RE: What's wrong with your HEAD? - pier4r - 10-08-2018, 09:55 AM
RE: What's wrong with your HEAD? - Werner - 10-08-2018, 11:03 AM
RE: What's wrong with your HEAD? - pier4r - 10-08-2018, 02:08 PM
RE: What's wrong with your HEAD? - 3298 - 10-08-2018, 05:55 PM
RE: What's wrong with your HEAD? - DavidM - 10-08-2018, 07:47 PM
RE: What's wrong with your HEAD? - pier4r - 10-10-2018, 11:07 AM
RE: What's wrong with your HEAD? - DavidM - 10-10-2018, 02:56 PM
RE: What's wrong with your HEAD? - 3298 - 10-10-2018, 05:41 PM
RE: What's wrong with your HEAD? - DavidM - 10-19-2018, 01:52 AM
RE: What's wrong with your HEAD? - pier4r - 10-20-2018, 05:37 PM



User(s) browsing this thread: 1 Guest(s)