D3.js - custom key function

JavaScript performance comparison

Revision 2 of this test case created

Info

.append() vs html()

Preparation code

<script src="//d3js.org/d3.v2.js"></script>

<div id='data'>
</div>

<script>

var data =
[
  "",
  "navigation",
  "search",
  "",
  "",
  "IBM",
  "Lenovo",
  "Laptop",
  "Operating system",
  "Windows",
  "laptop computers",
  "tablets",
  "IBM",
  "Lenovo",
  "Bento",
  "[1]",
  "power users",
  "International Space Station",
  "[2]",
  "1 History",
  "1.1 Name",
  "1.2 Early models",
  "1.3 Industrial design",
  "1.4 Reviews and awards",
  "1.5 Use in space",
  "1.6 Acquisition by Lenovo",
  "1.7 Manufacturing",
  "2 Recent models",
  "2.1 ThinkPad Twist",
  "2.2 ThinkPad tablets",
  "2.2.1 ThinkPad Helix",
  "2.2.2 ThinkPad Tablet 2",
  "2.2.3 ThinkPad Tablet",
  "2.3 T Series",
  "2.4 W Series",
  "2.5 X Series",
  "2.5.1 ThinkPad X100e",
  "2.5.2 ThinkPad X120e",
  "2.5.3 ThinkPad X130e",
  "2.5.4 ThinkPad X60 series",
  "2.5.5 ThinkPad X300/X301",
  "2.5.6 ThinkPad X200/X200s, X220, X230",
  "2.5.7 ThinkPad X1",
  "2.5.8 ThinkPad X1 Carbon",
  "2.6 L Series",
  "2.7 Edge Series",
  "3 Legacy models",
  "3.1 ThinkPad 235",
  "3.2 ThinkPad 240",
  "3.3 ThinkPad 300 series",
  "3.4 ThinkPad 500 series",
  "3.5 ThinkPad 600 series",
  "3.6 ThinkPad 700 series",
  "3.7 ThinkPad 800 series",
  "3.8 ThinkPad Z60 series",
  "3.9 SL Series",
  "3.10 A31",
  "4 See also",
  "5 References",
  "6 External links",
  "edit",
  "edit",
  "",
  "",
  "Thomas J. Watson, Sr",
  "\"THINK\"",
  "[3]",
  "[4]",
  "[5]",
  "[6]",
  "edit",
  "[5]",
  "486SLC",
  "MB",
  "TFT",
  "[5]",
  "tablet design",
  "pointing stick",
  "[7]",
  "edit",
  "",
  "",
  "TrackPoint",
  "carbon fiber",
  "titanium",
  "TrackPoint",
  "ThinkLight",
  "accelerometer",
  "roll cage",
  "Trusted Platform Module",
  "ThinkVantage Technologies",
  "Tom Hardy",
  "Richard Sapper",
  "Tizio lamp",
  "Artemide",
  "Knoll",
  "Alessi",
  "Lamy",
  "Japan",
  "[8]",
  "[9]",
  "[10]",
  "Shōkadō bentō",
  "[8]",
  "[11]",
  "David Hill",
  "butterfly keyboard",
  "Museum of Modern Art",
  "",
  "",
  "overhead projector",
  "data projectors",
  "[12]",
  "edit",
  "computer keyboard",
  "[13]",
  "[14]",
  "[15]",
  "[16]",
  "[17]",
  "[18]",
  "[19]",
  "PC World",
  "[20]",
  "eMachines",
  "[21]",
  "Greenpeace",
  "[22]",
  "[23]",
  "[24]",
  "[25]",
  "[26]",
  "edit",
  "",
  "",
  "",
  "",
  "",
  "",
  "[27]",
  "Space Shuttle Endeavour",
  "Hubble Space Telescope",
  "NASA",
  "[28]",
  "International Space Station",
  "[2]",
  "IP phone",
  "[29]",
  "LAN",
  "[30]",
  "Wi-Fi",
  "DSL",
  "[29]",
  "edit",
  "",
  "",
  "Lenovo",
  "edit",
  "Yamagata",
  "[31]",
  "edit",
  "edit",
  "Lenovo ThinkPad Twist",
  "[32]",
  "edit",
  "edit",
  "ThinkPad Helix",
  "Gorilla Glass",
  "[33]",
  "edit",
  "ThinkPad Tablet 2",
  "Windows 8",
  "[34]",
  "Windows 8",
  "[34]",
  "[35]",
  "Intel Atom",
  "CNET",
  "mini-HDMI",
  "[34]",
  "[35]",
  "edit",
  "ThinkPad Tablet",
  "[36]",
  "[37]",
  "Cisco",
  "[38]",
  "IBM's",
  "Lotus Notes Traveler",
  "[39]",
  "[39]",
  "[39]",
  "[39]",
  "[40]",
  "edit",
  "",
  "",
  "ultraportable",
  "IBM",
  "ThinkPad T Series",
  "Lenovo UltraBay",
  "ThinkLight",
  "edit",
  "ThinkPad W Series",
  "Nvidia Quadro",
  "graphics processor",
  "edit",
  "ThinkPad X Series",
  "",
  "",
  "",
  "",
  "ThinkLight",
  "chiclet keyboard",
  "[41]",
  "edit",
  "edit",
  "edit",
  "Australian",
  "Digital Education Revolution",
  "edit",
  "Santa Rosa platform",
  "edit",
  "solid state drive",
  "TDP",
  "Centrino 2",
  "edit",
  "[42]",
  "edit",
  "edit",
  "ThinkPad X1 Carbon",
  "solid-state drive",
  "[43]",
  "[43]",
  "CNET",
  "[44]",
  "edit",
  "edit",
  "ThinkPad Edge",
  "[45]",
  "island-style keyboard",
  "[46]",
  "edit",
  "",
  "",
  "",
  "",
  "",
  "",
  "edit",
  "Intel",
  "Pentium MMX",
  "Hitachi",
  "edit",
  "240",
  "Celeron",
  "Pentium III",
  "Intel 440BX",
  "Mini PCI",
  "edit",
  "310",
  "380",
  "edit",
  "edit",
  "memory effect",
  "edit",
  "760",
  "770",
  "tablet PC",
  "edit",
  "PowerPC",
  "x86",
  "PowerPC 603e",
  "SCSI",
  "Windows NT",
  "OS/2",
  "AIX",
  "Solaris",
  "Linux",
  "edit",
  "Z60m",
  "Yonah",
  "Intel VT-x",
  "operating systems",
  "Xen",
  "VMware",
  "[47]",
  "edit",
  "[48]",
  "edit",
  "edit",
  "",
  "Information technology  portal",
  "IdeaPad",
  "Lenovo UltraBay",
  "List of IBM products",
  "ThinkCentre",
  "HP EliteBook",
  "edit",
  "^",
  "\"Design Matters: The Bento Box\"",
  "http://www.lenovoblogs.com/designmatters/2006/10/the-bento-box/",
  "a",
  "b",
  "\"IBM ThinkPads in space\"",
  "IBM",
  "the original",
  "http://web.archive.org/web/20110720220124/http://www-03.ibm.com/ibm/history/exhibits/space/space_thinkpad.html",
  "^",
  "\"The History of the ThinkPad Name\"",
  "http://www.osnews.com/story/22274/The_History_of_the_ThinkPad_Name",
  "^",
  "McGraw Hill Professional",
  "a",
  "b",
  "c",
  "\"IBM Highlights, 1990 -1995\"",
  "IBM",
  "http://www-03.ibm.com/ibm/history/documents/pdf/1990-1995.pdf",
  "^",
  "ThinkPads.com documents on ThinkPads",
  "dead link",
  "^",
  "\"IBM Archives: 1992\"",
  "IBM",
  "http://www-03.ibm.com/ibm/history/history/year_1992.html",
  "a",
  "b",
  "New York City",
  "McGraw-Hill",
  "^",
  "\"25 Years of PC Magazine: Year Eleven/1992\"",
  "PC Magazine",
  "^",
  "^",
  "Reed-electronics.com",
  "dead link",
  "^",
  "available online",
  "^",
  "Lenovo \"Lenovo ThinkPad T60: Light business notebook with performance to spare\"",
  "http://laptopmag.com/Review/Lenovo-ThinkPad-T60.htm",
  "^",
  "\"Is Tech Support Getting Worse? - Notebooks - Reviews by PC Magazine\"",
  "http://www.pcmag.com/article2/0,2817,2184107,00.asp",
  "^",
  "\"The 19th Annual Reader Satisfaction Survey - Readers' Choice: Notebooks Survey - News and Analysis by PC Magazine\"",
  "http://www.pcmag.com/article2/0,1895,2006499,00.asp",
  "^",
  "\"Best of 2004\"",
  "http://www.pcworld.com/news/article/0,aid,116015,pg,2,00.asp",
  "^",
  "Buying Guide: Business Laptops - Lenovo ThinkPad X60 Tablet - Reviews by PC Magazine",
  "dead link",
  "^",
  "\"Lenovo ThinkPad X60s Review\"",
  "http://www.pcworld.com/article/id,125610-page,1-c,notebooks/article.html",
  "^",
  "\"The 100 Best Products of 2006\"",
  "http://www.pcworld.com/article/id,125706-page,14-c,technology/article.html",
  "^",
  "\"Reliability and Service: The Best Companies to Buy From\"",
  "http://www.pcworld.com/article/id,123409-page,9/article.html",
  "^",
  "\"Reliability and Service: Readers Rate the Manufacturers\"",
  "http://www.pcworld.com/article/id,118514-page,5/article.html",
  "^",
  "\"Chinese company tops Greenpeace \"Green Ranking\" of electronics industry | Greenpeace International\"",
  "http://www.greenpeace.org/international/news/chinese-company-tops-greenpeac",
  "^",
  "How the companies line up | Greenpeace International",
  "dead link",
  "^",
  "\"Lenovo ThinkPad T60p - Reviews by PC Magazine\"",
  "http://www.pcmag.com/article2/0,1895,2098002,00.asp",
  "^",
  "\"Lightning-Fast Surfing, To Go - Lenovo ThinkPad X60 (Vista) - Reviews by PC Magazine\"",
  "http://www.pcmag.com/article2/0,1895,2091476,00.asp",
  "^",
  "\"The PC World 100: Best Products of 2009\"",
  "http://www.pcworld.com/article/174171-3/the_pc_world_100_best_products_of_2009.html",
  "^",
  "2001: A Space Laptop",
  "^",
  "\"IBM Archives: 1993\"",
  "IBM",
  "http://www-03.ibm.com/ibm/history/history/year_1993.html",
  "a",
  "b",
  "\"First Tweet From Space\"",
  "The New York Times",
  "http://bits.blogs.nytimes.com/2010/01/22/first-tweet-from-space/",
  "^",
  "\"2011-06-07 Daily ISS Report\"",
  "NASA",
  "http://www.nasa.gov/directorates/somd/reports/iss_reports/2011/06072011.html",
  "^",
  "\"Lenovo Moves ThinkPad Production Back to Japan\"",
  "http://news.softpedia.com/news/Lenovo-Moves-ThinkPad-Production-Back-to-Japan-279443.shtml?utm_source=ForumSoftpedia&utm_medium=ForumSoftpedia&utm_campaign=ForumSoftpedia",
  "^",
  "Hands on: Lenovo ThinkPad Twist review",
  "^",
  "Lenovo announces ThinkPad Helix and IdeaPad Yoga 11S convertibles",
  "a",
  "b",
  "c",
  "\"Lenovo ThinkPad Tablet 2\"",
  "http://reviews.cnet.com/tablets/lenovo-thinkpad-tablet-2/4505-3126_7-35411720.html",
  "a",
  "b",
  "\"Lenovo unveils new Atom-powered ThinkPad Tablet 2 with Windows 8\"",
  "http://arstechnica.com/gadgets/2012/08/lenovo-unveils-new-atom-powered-thinkpad-tablet-2-with-windows-8/",
  "^",
  "\"Lenovo ThinkPad Tablet gets an August 23rd release\"",
  "http://www.engadget.com/2011/07/29/lenovo-thinkpad-tablet-gets-an-august-23rd-release/",
  "^",
  "\"Lenovo ThinkPad Tablet overview\"",
  "http://gadgetmix.com/thinkpad/lenovo-thinkpad/",
  "^",
  "\"Lenovo ThinkPad Tablet preview: Lenovo brings its corporate-looking design to the tablet market\"",
  "http://www.pcworld.idg.com.au/review/broadband/lenovo/thinkpad_tablet/394478",
  "a",
  "b",
  "c",
  "d",
  "\"Lenovo Announces ThinkPad Tablet for Businesses\"",
  "http://www.pcworld.com/article/236058/lenovo_announces_thinkpad_tablet_for_businesses.html",
  "^",
  "\"Lenovo IdeaPad K1 and ThinkPad Tablet hands-on\"",
  "http://www.slashgear.com/lenovo-ideapad-k1-and-thinkpad-tablet-hands-on-19166143/",
  "^",
  "White Thinkpad X100e unboxed",
  "^",
  "\"Lenovo ThinkPad X200 Tablet (Multitouch)\"",
  "http://www.pcmag.com/article2/0,2817,2353585,00.asp",
  "a",
  "b",
  "\"Magid on Tech: Lenovo's new X1 Carbon a top-notch ultrabook\"",
  "http://www.mercurynews.com/breaking-news/ci_21313681/magid-review-lenovo-ultrabook-x1-carbon-pc-macbook-air",
  "^",
  "http://www.cnet.com/laptops/lenovo-thinkpad-x1-carbon/4505-3121_7-35299011.html",
  "^",
  "\"Lenovo Announces Premium ThinkPad Edge E220s, E420s SMB Notebooks\"",
  "http://www.thinkpads.com/2011/01/03/lenovo-announces-premium-thinkpad-edge-e220s-e420s-smb-notebooks/",
  "^",
  "\"Lenovo ThinkPad Edge 11 announced with Intel and AMD options, denied US citizenship\"",
  "Engadget",
  "http://www.engadget.com/2010/09/28/lenovo-thinkpad-edge-11-announced-with-intel-and-amd-options-de/",
  "^",
  "\"Building the Perfect Laptop\"",
  "http://www.businessweek.com/magazine/content/08_08/b4072042350389.htm?chan=magazine+channel_top+stories",
  "^",
  "\"ThinkPad SL Series\"",
  "http://www.lenovoblogs.com/insidethebox/2008/07/thinkpad-sl-series/",
  "edit",
  "ThinkPad",
  "thinkpad.com",
  "ThinkPad models",
  "Collection of manuals for Thinkpads",
  "v",
  "t",
  "e",
  "Lenovo",
  "ThinkCentre",
  "A Series",
  "M Series",
  "Edge Series",
  "IdeaCentre",
  "A Series",
  "B Series",
  "Q Series",
  "K Series",
  "Essential Desktops",
  "T Series",
  "Edge Series",
  "X Series",
  "W Series",
  "L Series",
  "IdeaPad",
  "S Series",
  "Z Series",
  "Y Series",
  "U Series",
  "Essential Laptops",
  "IdeaPad Yoga",
  "ThinkServer",
  "ThinkPad",
  "IdeaPad",
  "WorkPad",
  "ThinkStation",
  "ThinkVantage",
  "Secure Managed Client",
  "LePhone",
  "LeTV",
  "ThinkLight",
  "UltraBay",
  "Skylight",
  "",
  "Liu Chuanzhi",
  "Legend Holdings",
  "Medion",
  "Yang Yuanqing",
  "Category",
  "Commons",
  "http://en.wikipedia.org/w/index.php?title=ThinkPad&oldid=532253018",
  "Categories",
  "Consumer electronics brands",
  "1992 introductions",
  "IBM laptops",
  "Lenovo laptops",
  "All articles with dead external links",
  "Articles with dead external links from April 2012",
  "Commons category template with no category set",
  "Create account",
  "Log in",
  "Article",
  "Talk",
  "",
  "Read",
  "Edit",
  "View history",
  "",
  "",
  "Main page",
  "Contents",
  "Featured content",
  "Current events",
  "Random article",
  "Donate to Wikipedia",
  "Help",
  "About Wikipedia",
  "Community portal",
  "Recent changes",
  "Contact Wikipedia",
  "What links here",
  "Related changes",
  "Upload file",
  "Special pages",
  "Permanent link",
  "Page information",
  "Cite this page",
  "Create a book",
  "Download as PDF",
  "Printable version",
  "Català",
  "Česky",
  "Dansk",
  "Deutsch",
  "Eesti",
  "Español",
  "Français",
  "한국어",
  "हिन्दी",
  "Italiano",
  "日本語",
  "Norsk (bokmål)‎",
  "Polski",
  "Português",
  "Русский",
  "Suomi",
  "Svenska",
  "Türkçe",
  "中文",
  "Creative Commons Attribution-ShareAlike License",
  "",
  "Terms of Use",
  "Wikimedia Foundation, Inc.",
  "Contact us",
  "Privacy policy",
  "About Wikipedia",
  "Disclaimers",
  "Mobile view",
  "",
  ""
]

d3.select("#data").selectAll("p")
.data(data)
.enter()
  .append("p")
  .text(function (d) { return d; })
</script>
 

Preparation code output

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
no key function
var head = data.shift()
data.push(head)

var p = d3.select("#data").selectAll("p")
.data(data);

p.enter()
  .append("p")
p.text(function (d) { return d; })
p.exit().remove()
pending…
custom key function
var head = data.shift()
data.push(head)

var p = d3.select("#data").selectAll("p")
.data(data, function (x) { return x });

p.enter()
  .append("p")
p.text(function (d) { return d; })
p.exit().remove()
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment