{"id":656,"date":"2017-08-31T11:03:19","date_gmt":"2017-08-31T09:03:19","guid":{"rendered":"http:\/\/blogs.igalia.com\/xrcalvar\/?p=656"},"modified":"2017-09-04T08:56:31","modified_gmt":"2017-09-04T06:56:31","slug":"some-rough-numbers-on-webkit-code","status":"publish","type":"post","link":"https:\/\/blogs.igalia.com\/xrcalvar\/2017\/08\/31\/some-rough-numbers-on-webkit-code\/","title":{"rendered":"Some rough numbers on WebKit code"},"content":{"rendered":"<p>My <a href=\"https:\/\/twitter.com\/lauramcastro\">wife<\/a> asked me for some rough LOC numbers on the <a href=\"http:\/\/www.webkit.org\">WebKit<\/a> project and I think I could share them with you here as well. They come from <a href=\"https:\/\/trac.webkit.org\/changeset\/221232\/webkit\">r221232<\/a>. As I&#8217;ll take into account some generated code it is relevant to mention that I built <a href=\"https:\/\/webkitgtk.org\/\">WebKitGTK+<\/a> with the default <em>CMake<\/em> options.<\/p>\n<p>First thing I did was running <code>sloccount Source<\/code> and got the following numbers:<\/p>\n<p><code>cpp:        2526061 (70.57%)<br \/>\nansic:       396906 (11.09%)<br \/>\nasm:         207284 (5.79%)<br \/>\njavascript:    175059 (4.89%)<br \/>\njava:         74458 (2.08%)<br \/>\nperl:         73331 (2.05%)<br \/>\nobjc:         44422 (1.24%)<br \/>\npython:       38862 (1.09%)<br \/>\ncs:           13011 (0.36%)<br \/>\nruby:         11605 (0.32%)<br \/>\nxml:          11396 (0.32%)<br \/>\nsh:            3747 (0.10%)<br \/>\nyacc:          2167 (0.06%)<br \/>\nlex:           1007 (0.03%)<br \/>\nlisp:            89 (0.00%)<br \/>\nphp:             10 (0.00%)<\/code><\/p>\n<p>This number do not include IDL code so I did some <em>grepping<\/em> to get the number myself that gave me <em>19632<\/em> IDL lines:<\/p>\n<p><code>$ find Source\/ -name \"<em>.idl\" | xargs cat | grep -ve \"^[[:space:]]<\/em>\\\/&#42;\" -ve \"^[[:space:]]<em>&#42;\" -ve \"^[[:space:]]<\/em>$\" -ve \"^[[:space:]]<em>&#91;$\" -ve \"^[[:space:]]<\/em>&#125;;$\" | wc -l<br \/>\n19632<\/code><\/p>\n<p>The interesting part of the IDL files is that they are used to generate code so those 19632 IDL lines expand to:<\/p>\n<p><code>ansic:       699140 (65.25%)<br \/>\ncpp:         368720 (34.41%)<br \/>\npython:        1492 (0.14%)<br \/>\nxml:           1040 (0.10%)<br \/>\njavascript:       883 (0.08%)<br \/>\nasm:            169 (0.02%)<br \/>\nperl:            11 (0.00%)<\/code><\/p>\n<p>Let&#8217;s have a look now at the <em>LayoutTests<\/em> (they test the functionality of <em>WebCore<\/em> + the platform). Tests are composed mainly by <em>HTML<\/em> files so if you run <code>sloccount LayoutTests<\/code> you get:<\/p>\n<p><code>javascript:    401159 (76.74%)<br \/>\npython:       87231 (16.69%)<br \/>\nxml:          22978 (4.40%)<br \/>\nphp:           4784 (0.92%)<br \/>\nansic:         3661 (0.70%)<br \/>\nperl:          2726 (0.52%)<br \/>\nsh:             199 (0.04%)<\/code><\/p>\n<p>It&#8217;s quite interesting to see that <em>sloccount<\/em> does not consider <em>HTML<\/em> which is quite relevant when you&#8217;re testing a web engine so again, we have to count them manually (thanks to <a href=\"https:\/\/www.igalia.com\/nc\/igalia-247\/igalian\/item\/clopez\/\">Carlos L\u00f3pez<\/a> who helped me to properly grep here as some binary lines were giving me a headache to get the numbers):<\/p>\n<p><code>find LayoutTests\/ -name \"<em>.html\" -print0 | xargs -0 cat | strings | grep -Pv \"^[[:space:]]<\/em>$\" | wc -l<br \/>\n2205690<\/code><\/p>\n<p>You can see 2205690 of &#8220;meaningful lines&#8221; that combine <em>HTML<\/em> + other languages that you can see above. I can&#8217;t substract here to just get the <em>HTML<\/em> lines because the number above take into account files with a different extension than <em>HTML<\/em>, though many of them do include other languages, specially <em>JavaScript<\/em>.<\/p>\n<p>But the <em>LayoutTests<\/em> do not include only pure WebKit tests. There are some imported ones so it might be interesting to run the same procedure under <code>LayoutTests\/imported<\/code> to see which ones are imported and not written directly <em>into the WebKit project<\/em>. I emphasize that because they can be written by WebKit developers in other repositories and actually I can present myself and Youenn Fablet as an example as we wrote tests some tests that were finally moved into the specification and included back later when imported. So again, <code>sloccount LayoutTests\/imported<\/code>:<\/p>\n<p><code>python:       84803 (59.99%)<br \/>\njavascript:     51794 (36.64%)<br \/>\nansic:         3661 (2.59%)<br \/>\nphp:            575 (0.41%)<br \/>\nxml:            250 (0.18%)<br \/>\nsh:             199 (0.14%)<br \/>\nperl:            86 (0.06%)<\/code><\/p>\n<p>The same procedure to count <em>HTML + other stuff<\/em> lines inside that directory gives a number of 295490:<\/p>\n<p><code>$ find LayoutTests\/imported\/ -name \"<em>.html\" -print0 | xargs -0 cat | strings | grep -Pv \"^[[:space:]]<\/em>$\" | wc -l<br \/>\n295490<\/code><\/p>\n<p>There are also some other tests that we can talk about, for example the <em>JSTests<\/em>. I&#8217;ll mention already the numbers summed up regarding languages and the manual <em>HTML<\/em> code (if you made it here, you know the drill already):<\/p>\n<p><code>javascript:   1713200 (98.64%)<br \/>\nxml:          20665 (1.19%)<br \/>\nperl:          2449 (0.14%)<br \/>\npython:         421 (0.02%)<br \/>\nruby:            56 (0.00%)<br \/>\nsh:              38 (0.00%)<br \/>\nHTML+stuff: 997<\/code><\/p>\n<p><em>ManualTests<\/em>:<\/p>\n<p><code>javascript:       297 (41.02%)<br \/>\nansic:          187 (25.83%)<br \/>\njava:           118 (16.30%)<br \/>\nxml:            103 (14.23%)<br \/>\nphp:             10 (1.38%)<br \/>\nperl:             9 (1.24%)<br \/>\nHTML+stuff: 16026<\/code><\/p>\n<p><em>PerformanceTests<\/em>:<\/p>\n<p><code>javascript:    950916 (83.12%)<br \/>\ncpp:         147194 (12.87%)<br \/>\nansic:        38540 (3.37%)<br \/>\nasm:           5466 (0.48%)<br \/>\nsh:             872 (0.08%)<br \/>\nruby:           419 (0.04%)<br \/>\nperl:           348 (0.03%)<br \/>\npython:         325 (0.03%)<br \/>\nxml:              5 (0.00%)<br \/>\nHTML+stuff: 238002<\/code><\/p>\n<p><em>TestsWebKitAPI<\/em>:<\/p>\n<p><code>cpp:          44753 (99.45%)<br \/>\nansic:          163 (0.36%)<br \/>\nobjc:            76 (0.17%)<br \/>\nxml:              7 (0.02%)<br \/>\njavascript:         1 (0.00%)<br \/>\nHTML+stuff: 3887<\/code><\/p>\n<p>And this is all. Remember that these are just some rough statistics, not a &#8220;scientific&#8221; paper.<\/p>\n<p><strong>Update:<\/strong><\/p>\n<p>In her expert opinion, in the WebKit project we are devoting around 50% of the total LOC to testing, which makes it a software engineering &#8220;textbook&#8221; project regarding testing and I think we can be proud of it!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>My wife asked me for some rough LOC numbers on the WebKit project and I think I could share them with you here as well. They come from r221232. As I&#8217;ll take into account some generated code it is relevant &hellip; <a href=\"https:\/\/blogs.igalia.com\/xrcalvar\/2017\/08\/31\/some-rough-numbers-on-webkit-code\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":31,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,8,9,43,44],"tags":[74,75,33,41],"class_list":["post-656","post","type-post","status-publish","format-standard","hentry","category-igaliacom","category-planet-gpul","category-planet-igalia","category-planet-webkit","category-planet-webkitgtk","tag-code","tag-loc","tag-tests","tag-webkit"],"_links":{"self":[{"href":"https:\/\/blogs.igalia.com\/xrcalvar\/wp-json\/wp\/v2\/posts\/656","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.igalia.com\/xrcalvar\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.igalia.com\/xrcalvar\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.igalia.com\/xrcalvar\/wp-json\/wp\/v2\/users\/31"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.igalia.com\/xrcalvar\/wp-json\/wp\/v2\/comments?post=656"}],"version-history":[{"count":28,"href":"https:\/\/blogs.igalia.com\/xrcalvar\/wp-json\/wp\/v2\/posts\/656\/revisions"}],"predecessor-version":[{"id":684,"href":"https:\/\/blogs.igalia.com\/xrcalvar\/wp-json\/wp\/v2\/posts\/656\/revisions\/684"}],"wp:attachment":[{"href":"https:\/\/blogs.igalia.com\/xrcalvar\/wp-json\/wp\/v2\/media?parent=656"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.igalia.com\/xrcalvar\/wp-json\/wp\/v2\/categories?post=656"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.igalia.com\/xrcalvar\/wp-json\/wp\/v2\/tags?post=656"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}