{"id":299227,"date":"2020-02-25T15:00:15","date_gmt":"2020-02-25T15:00:15","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=299227"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=299227","title":{"rendered":"\u041e\u0447\u0435\u0440\u0435\u0434\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u0440\u043e wc"},"content":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/489898\/\">\n<p>\u0412\u0441\u0435\u043c \u0434\u043e\u0431\u0440\u044b\u0439 \u0434\u0435\u043d\u044c.<\/p>\n<p>  <\/p>\n<p>\u041d\u0435\u0434\u0430\u0432\u043d\u043e \u043d\u0430 \u0425\u0430\u0431\u0440\u0435 \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u0441\u0442\u0430\u0442\u044c\u044f <a href=\"https:\/\/habr.com\/ru\/post\/489136\">\u041f\u043e\u0431\u0435\u0436\u0434\u0430\u044f C \u0434\u0432\u0430\u0434\u0446\u0430\u0442\u044c\u044e \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438 Haskell: \u043f\u0438\u0448\u0435\u043c \u0441\u0432\u043e\u0439 wc<\/a> \u043e\u0442 <a href=\"https:\/\/habr.com\/ru\/users\/0xd34df00d\/\">@0xd34df00d<\/a>. \u0410\u0432\u0442\u043e\u0440, \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0439 \u0441\u0432\u043e\u0435\u0439 \u0441\u0438\u043c\u043f\u0430\u0442\u0438\u0435\u0439 \u043a \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e, \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b \u043d\u0430 \u0425\u0430\u0441\u043a\u0435\u043b\u0435 \u0430\u043d\u0430\u043b\u043e\u0433 \u0443\u0442\u0438\u043b\u0438\u0442\u044b <i>wc<\/i>, \u0438 \u043f\u043e\u0434\u0432\u0435\u0440\u0433 \u0435\u0433\u043e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438, \u043f\u043e\u043b\u0443\u0447\u0438\u0432 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439 \u0431\u043e\u043b\u0435\u0435 \u0447\u0435\u043c \u0432 7 \u0440\u0430\u0437 \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u044e\u043d\u0438\u043a\u0441\u043e\u0432\u043e\u0439 \u0443\u0442\u0438\u043b\u0438\u0442\u044b.<a name=\"habracut\"><\/a><\/p>\n<p>  <\/p>\n<p>\u0411\u0443\u0434\u0443\u0447\u0438 \u0434\u043e\u0431\u0440\u043e\u0441\u043e\u0432\u0435\u0441\u0442\u043d\u044b\u043c &quot;\u0431\u0435\u043d\u0447\u043c\u0430\u0440\u043a\u0435\u0440\u043e\u043c&quot;, <a href=\"https:\/\/habr.com\/ru\/users\/0xd34df00d\/\" class=\"user_link\">0xd34df00d<\/a> \u0432 \u043a\u043e\u043d\u0446\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 \u0443\u043a\u0430\u0437\u0430\u043b, \u0447\u0442\u043e \u0435\u0433\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u0441\u0438\u043b\u044c\u043d\u043e \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u044b\u043c \u0422\u0417 \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u043e\u043c (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0431\u044b\u043b \u043f\u0440\u043e\u0438\u0433\u043d\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u043d Unicode), \u0438 \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0435\u0433\u043e \u043f\u0440\u0435\u0432\u043e\u0441\u0445\u043e\u0434\u0441\u0442\u0432\u043e \u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043d\u0438\u0447\u0435\u0433\u043e \u043f\u043e \u0444\u0430\u043a\u0442\u0443 \u043d\u0435 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442. \u041d\u043e \u044f\u0441\u043d\u043e\u0435 \u0434\u0435\u043b\u043e, \u0447\u0442\u043e \u043d\u0435 \u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u044d\u0442\u043e \u0444\u043e\u0440\u043c\u0430\u0442 \u0441\u0442\u0430\u0442\u044c\u0438 \u043f\u043e\u0440\u043e\u0434\u0438\u043b \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0441\u043f\u043e\u0440\u043e\u0432 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 (\u0434\u0430 \u044f \u0438 \u0441\u0430\u043c \u0447\u0430\u0441\u0442\u043e \u043d\u0435 \u0447\u0438\u0442\u0430\u044e \u0434\u0430\u043b\u044c\u0448\u0435 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430, \u0447\u0435\u0433\u043e \u0433\u0440\u0435\u0445\u0430 \u0442\u0430\u0438\u0442\u044c). \u041f\u043e\u0434 \u0441\u0442\u0430\u0442\u044c\u0435\u0439 <a href=\"https:\/\/habr.com\/ru\/users\/yleo\/\" class=\"user_link\">yleo<\/a> \u043f\u0440\u0438\u0432\u0435\u043b \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0433\u043e \u0438\u043c \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043d\u0430 C (\u043f\u043e\u0434 \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u043e\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435), \u043f\u043e\u043a\u0430\u0437\u0430\u0432, \u0447\u0442\u043e \u0434\u0430\u0436\u0435 \u043d\u0430\u0438\u0432\u043d\u0430\u044f C-\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043e\u0431\u0445\u043e\u0434\u0438\u0442 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 Haskell-\u0432\u0430\u0440\u0438\u0430\u043d\u0442. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0433\u043e\u0441\u043f\u043e\u0434\u0430 \u043f\u0440\u0438\u043d\u044f\u043b\u0438\u0441\u044c \u043a\u0438\u0434\u0430\u0442\u044c\u0441\u044f \u0434\u0440\u0443\u0433 \u0432 \u0434\u0440\u0443\u0433\u0430 <del>\u043a\u0430<\/del>\u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u043c\u0438, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u0440\u0438\u0434\u0438\u0440\u0430\u043b\u0438\u0441\u044c \u043a \u043c\u0435\u043b\u043a\u0438\u043c \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u044f\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u0438\u0445 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 (\u044d\u0442\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043c\u043e\u0435 \u043b\u0438\u0447\u043d\u043e\u0435 \u0432\u0438\u0434\u0435\u043d\u0438\u0435 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438).<\/p>\n<p>  <\/p>\n<p>\u0421\u043f\u0443\u0441\u0442\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u0448\u043b\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u0442\u043e\u0432\u0430\u0440\u0438\u0449\u0430 <a href=\"https:\/\/habr.com\/ru\/users\/chapuza\/\" class=\"user_link\">chapuza<\/a>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u044b\u043b\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u043e\u0433\u043e <em>wc<\/em> \u043d\u0430 Elixir, \u0442\u0430\u043a\u0436\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0430\u044f \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u0447\u0435\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0430\u044f. \u0412 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u043b\u0430\u0441\u044c \u0434\u0438\u0441\u043a\u0443\u0441\u0441\u0438\u044f \u0438\u0437 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043f\u043e\u0441\u0442\u0430, \u0445\u043e\u0442\u044f \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u0431\u044b\u043b\u043e\u0439 \u0437\u0430\u043f\u0430\u043b \u0431\u044b\u043b \u0443\u0442\u0440\u0430\u0447\u0435\u043d.<\/p>\n<p>  <\/p>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u043f\u043e\u0431\u0435\u0434\u0438\u0442\u044c \u043e\u0434\u0438\u043d \u044f\u0437\u044b\u043a\/\u043f\u0430\u0440\u0430\u0434\u0438\u0433\u043c\u0443 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u0440\u0443\u0433\u0438\u043c\/\u0434\u0440\u0443\u0433\u043e\u0439. \u0414\u0443\u043c\u0430\u044e, \u043d\u0435 \u043f\u0440\u0435\u0434\u0432\u0437\u044f\u0442\u043e\u043c\u0443 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0443 \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e C \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u0433\u0438\u0431\u0447\u0435 \u0432 \u043f\u043b\u0430\u043d\u0435 \u0440\u0443\u0447\u043d\u043e\u0439 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0447\u0435\u043c Haskell \u0438 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0434\u0440\u0443\u0433\u0438\u0445 \u044f\u0437\u044b\u043a\u043e\u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0438 \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043a\u043e\u0434 \u043d\u0430 C \u0445\u043e\u0442\u044c \u0438 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435 \u0447\u0435\u043c \u043d\u0430 Haskell, \u043d\u043e \u0442\u0430\u043a \u0436\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438 \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u2014 \u0432\u0441\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0442\u043e\u0433\u043e, \u043a\u0442\u043e \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u043f\u0438\u0448\u0435\u0442. \u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u043b\u0438\u0447\u043d\u043e \u044f \u0432\u0438\u0436\u0443 \u043c\u043d\u043e\u0433\u043e \u043f\u043e\u043a\u0430 \u0447\u0442\u043e \u043d\u0435 \u0440\u0430\u0441\u043a\u0440\u044b\u0442\u044b\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u043f\u0430\u0440\u0430\u0434\u0438\u0433\u043c\u044b, \u0438 \u043d\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438, \u0447\u0442\u043e \u043a\u043e\u0433\u0434\u0430 \u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u043a\u0440\u0443\u0442\u043e, \u0447\u0442\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u043e\u0433\u0430 \u043d\u0430 C \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0437\u0430\u0442\u0440\u0430\u0442\u043d\u044b\u043c \u0437\u0430\u043d\u044f\u0442\u0438\u0435\u043c. \u041d\u043e \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0438 \u0442\u0430\u043a, \u044d\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u0435\u0449\u0435 \u043d\u0435 \u043f\u0440\u0438\u0448\u043b\u043e.<\/p>\n<p>  <\/p>\n<p>\u0412 \u0442\u043e \u0436\u0435 \u0432\u0440\u0435\u043c\u044f, \u0431\u0443\u0434\u0443\u0447\u0438 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u043e\u043c, \u0447\u044c\u044e \u043b\u044e\u0431\u043e\u0432\u044c \u043a \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 (\u0434\u0430\u0436\u0435 \u0431\u0435\u0441\u0441\u043c\u044b\u0441\u043b\u0435\u043d\u043d\u043e\u0439) \u044f \u043e\u0446\u0435\u043d\u0438\u0432\u0430\u044e \u043a\u0430\u043a \u0444\u0430\u043d\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e, \u044f \u0441\u0440\u0430\u0437\u0443 \u0437\u0430\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u043b\u0441\u044f \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u044b\u0439 C-\u0432\u0430\u0440\u0438\u0430\u043d\u0442. \u042d\u0442\u0438\u043c \u043c\u044b \u0438 \u0437\u0430\u0439\u043c\u0435\u043c\u0441\u044f. \u0414\u0443\u043c\u0430\u044e, \u043d\u0430 \u0432\u043e\u043b\u043d\u0435 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0441\u0442\u0430\u0442\u0435\u0439 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u043a \u0442\u043e\u043c\u0443 \u0436\u0435, \u0441\u0430\u043c <a href=\"https:\/\/habr.com\/ru\/users\/0xd34df00d\/\" class=\"user_link\">0xd34df00d<\/a> \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u043a \u0441\u0432\u043e\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0432\u044b\u0440\u0430\u0437\u0438\u043b \u0438\u043d\u0442\u0435\u0440\u0435\u0441 \u043a \u043f\u043e\u0434\u0441\u0447\u0435\u0442\u0443 \u0441\u043b\u043e\u0432 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e &quot;simd-\u043c\u0430\u0433\u0438\u0438&quot;.<\/p>\n<p>  <\/p>\n<h3 id=\"testovyy-stend\">\u0422\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u0441\u0442\u0435\u043d\u0434<\/h3>\n<p>  <\/p>\n<p>\u0418\u0442\u0430\u043a, \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c \u0443\u0441\u043b\u043e\u0432\u0438\u044f, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0441\u043b\u043e\u0432\u0430.<\/p>\n<p>  <\/p>\n<pre><code class=\"cpp\">#include &lt;stdint.h&gt; #include &lt;stdio.h&gt; #include &lt;malloc.h&gt; #include &lt;Windows.h&gt; #include &lt;intrin.h&gt;  using namespace std;  struct stats {     uint32_t char_count;     uint32_t line_count;     uint32_t word_count; };  void word_count( unsigned char* const str, uint32_t size, stats&amp; result );  int main( ) {     FILE* f;     fopen_s( &amp;f, &quot;input.txt&quot;, &quot;rb&quot; );     fseek( f, 0, SEEK_END );     long size = ftell( f );     rewind( f );      long alloc_size = size + 63 - ( size + 63 ) % 64;     unsigned char* const data = (unsigned char*)_aligned_malloc( alloc_size, 64 );     fread( data, 1, size, f );     fclose( f );      LARGE_INTEGER fr, t0, t1;     QueryPerformanceFrequency( &amp;fr );     QueryPerformanceCounter( &amp;t0 );      stats result;     word_count2( data, size, result );      QueryPerformanceCounter( &amp;t1 );      _aligned_free( data );      double const time = (double)( t1.QuadPart - t0.QuadPart ) \/ (double)fr.QuadPart;     printf(         &quot;Words: %d; lines: %d; chars: %d\\nElapsed time: %lfms\\n&quot;,         result.word_count, result.line_count, result.char_count, time * 1000.0     );     system( &quot;pause&quot; ); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u2014 \u0434\u0430, \u044f \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Windows \u0438 Visual Studio. \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u043c\u043e\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0432\u043b\u0430\u0434\u0435\u043d\u0438\u044f Linux&#8217;\u043e\u043c \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0430\u0435\u0442\u0441\u044f \u043a \u043d\u0443\u043b\u044e, \u0438 \u043f\u0438\u0441\u0430\u0442\u044c Linux-\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0437\u043d\u0430\u0447\u0438\u043b\u043e \u0431\u044b \u043f\u043e\u0442\u0440\u0430\u0442\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u0443\u0441\u0438\u043b\u0438\u0439. \u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u043c\u044b \u0432\u0435\u0434\u044c \u043d\u0435 \u0441 \u043a\u0435\u043c \u043d\u0435 \u0441\u043e\u0440\u0435\u0432\u043d\u0443\u0435\u043c\u0441\u044f \u2014 \u0442\u0430\u043a \u0447\u0442\u043e \u043f\u0443\u0441\u0442\u044c \u0431\u0443\u0434\u0435\u0442 \u0443\u044e\u0442\u043d\u0430\u044f VS.<\/p>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0435, \u0432\u0441\u0435 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e. \u041c\u044b \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c \u0444\u0430\u0439\u043b \u0441 \u0434\u0438\u0441\u043a\u0430, \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u0437\u043d\u0430\u0432 \u0435\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440 \u0438 \u0432\u044b\u0434\u0435\u043b\u0438\u0432 \u043f\u043e\u0434 \u043d\u0435\u0433\u043e \u043f\u0430\u043c\u044f\u0442\u044c. \u041f\u0430\u043c\u044f\u0442\u044c \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u043c \u0432\u044b\u0440\u043e\u0432\u043d\u0435\u043d\u043d\u0443\u044e \u043f\u043e 64 \u0431\u0430\u0439\u0442\u0430 \u0438 \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0440\u0430\u0437\u043c\u0435\u0440 \u0430\u043b\u043b\u043e\u043a\u0430\u0446\u0438\u0438 \u0434\u043e 64 \u0431\u0430\u0439\u0442 \u2014 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u0434\u043b\u044f SIMD-\u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439, \u0434\u0430 \u0438 \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435 \u043f\u043e\u0432\u0440\u0435\u0434\u0438\u0442. \u0414\u0430\u043b\u0435\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u043e\u0434\u0441\u0447\u0435\u0442\u0430 \u0441\u043b\u043e\u0432, \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0442\u0440\u0435\u043a\u0430\u0435\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0430\u0439\u043c\u0435\u0440\u043e\u0432 \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438. (\u0421\u0442\u043e\u0438\u043b\u043e \u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u043d\u043e \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u043c\u043d\u0435 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u0435\u0439, \u043a \u0442\u043e\u043c\u0443 \u0436\u0435, \u043d\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0441\u043e\u043c\u043d\u0435\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0435\u0433\u043e \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438.) \u0414\u0430\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438 \u0437\u0430\u0442\u0440\u0430\u0447\u0435\u043d\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0432 \u043c\u0438\u043b\u043b\u0438\u0441\u0435\u043a\u0443\u043d\u0434\u0430\u0445, \u043d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u044f \u043e\u0441\u0432\u043e\u0431\u043e\u0434\u0438\u0442\u044c \u043f\u0430\u043c\u044f\u0442\u044c.<\/p>\n<p>  <\/p>\n<p>\u0411\u0443\u0434\u0435\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c, \u0447\u0442\u043e \u0432\u043e \u0432\u0445\u043e\u0434\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f Unicode, \u0438 \u0447\u0442\u043e \u043f\u0440\u043e\u0431\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u043a\u043e\u0434 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u0435\u043d\u044c\u0448\u0435 \u043b\u0438\u0431\u043e \u0440\u0430\u0432\u0435\u043d 32. \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430 \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0435, \u043d\u043e \u0442\u043e\u0433\u0434\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0443\u0442 \u0434\u0440\u0443\u0433\u0438\u043c\u0438. \u041a \u0442\u043e\u043c\u0443 \u0436\u0435, \u043c\u043d\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0447\u0442\u043e \u043f\u043e\u0434\u0441\u0447\u0435\u0442 \u0441\u043b\u043e\u0432 \u043e\u0431\u044b\u0447\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u0433\u0434\u0435 \u0442\u0430\u043a\u043e\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e.<\/p>\n<p>  <\/p>\n<p>\u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u043d\u0430 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0435 \u0441 \u043d\u043e\u0432\u0435\u043d\u044c\u043a\u0438\u043c Ryzen 5 3600 c \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u044c\u044e 2&#215;8 Gb 3200 MHz. \u0410\u0445 \u0434\u0430, \u0432\u0445\u043e\u0434\u043d\u043e\u0439 \u0444\u0430\u0439\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u0442\u043e\u0442 \u0436\u0435, \u0447\u0442\u043e \u0438 \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0441\u0442\u0430\u0442\u044c\u044f\u0445.<\/p>\n<p>  <\/p>\n<h3 id=\"trivialnaya-realizaciya\">\u0422\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/h3>\n<p>  <\/p>\n<p>\u041c\u043e\u0439 \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439:<\/p>\n<p>  <\/p>\n<pre><code class=\"cpp\">void word_count( unsigned char* const str, uint32_t size, stats&amp; result ) {     uint32_t lines = 1;     uint32_t words = 0;      bool was_space = false;      for ( uint32_t i = 0; i &lt; size; ++i )     {         unsigned char const c = str[i];         bool const is_space = c &lt;= ' ';         lines += ( c == '\\n' ) ? 1 : 0;         words += ( is_space &amp;&amp; !was_space ) ? 1 : 0;         was_space = is_space;     }      words += !was_space ? 1 : 0;      result.char_count = size;     result.line_count = lines;     result.word_count = words; }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e \u0441\u0443\u0442\u0438 \u043e\u043d \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0438\u0447\u0435\u043c \u043d\u0435 \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u0443\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u0433\u043e \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u043a \u0441\u0442\u0430\u0442\u044c\u0435 <a href=\"https:\/\/habr.com\/ru\/users\/0xd34df00d\/\" class=\"user_link\">0xd34df00d<\/a>. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0440\u0430\u0431\u043e\u0442\u044b:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">Words: 44774640; lines: 15000010; chars: 1871822228 Elapsed time: 1825.704800ms<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"simd-magiya-vyhodit-na-scenu\">(SIMD-\u043c\u0430\u0433\u0438\u044f \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u0441\u0446\u0435\u043d\u0443)<\/h3>\n<p>  <\/p>\n<p>\u0418\u0442\u0430\u043a, \u0447\u0442\u043e \u043c\u044b \u0432\u0438\u0434\u0438\u043c? \u0412\u0438\u0434\u0438\u043c \u0442\u043e, \u0447\u0442\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u0441\u0442\u0440\u043e\u043a\u0438 \u043f\u043e \u0441\u0443\u0442\u0438 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e (\u0434\u0430, \u0435\u0441\u0442\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0442 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u0430, \u043d\u043e <strong>\u043d\u0435 \u043e\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430<\/strong> \u0435\u0433\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438). \u0422\u0430\u043a \u043f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u043d\u0430\u043c \u043d\u0435 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043f\u043e 16 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e SSE-\u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439?<\/p>\n<p>  <\/p>\n<p>\u0412\u0430\u0440\u0438\u0430\u043d\u0442 \u0441 SSE:<\/p>\n<p>  <\/p>\n<pre><code class=\"cpp\">void word_count_sse( unsigned char* const str, uint32_t size, stats&amp; result ) {     uint32_t lines = 1;     uint32_t words = 0;      bool was_space = false;      for ( uint32_t i = 0; i &lt; size; i += 16 )     {         __m128i const c = _mm_load_si128( (__m128i*)( str + i ) );         uint32_t is_newline_mask = _mm_movemask_epi8(             _mm_cmpeq_epi8( c, _mm_set1_epi8( '\\n' ) )         );          uint32_t is_space_mask = _mm_movemask_epi8(             _mm_andnot_si128( c, _mm_cmplt_epi8( c, _mm_set1_epi8( ' ' + 1 ) ) )         );         uint32_t was_space_mask = ( was_space ? 1 : 0 ) | ( is_space_mask &lt;&lt; 1 );          lines += __popcnt( is_newline_mask );         words += __popcnt( is_space_mask &amp; ~was_space_mask );         was_space = is_space_mask &amp; 0x8000;     }      words += !was_space ? 1 : 0;      result.char_count = size;     result.line_count = lines;     result.word_count = words; }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u0443\u043c\u0430\u044e \u0441\u0442\u043e\u0438\u0442 \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c \u0447\u0442\u043e \u0442\u0443\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442. \u0423 \u043d\u0430\u0441 \u0432\u0441\u0435 \u0435\u0449\u0435 \u0435\u0441\u0442\u044c \u0444\u043b\u0430\u0433 <em>was_space<\/em>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0431\u044b\u043b \u043b\u0438 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u043f\u0440\u043e\u0431\u0435\u043b\u044c\u043d\u044b\u043c. \u0422\u0435\u043f\u0435\u0440\u044c, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u044b \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c 16 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0437\u0430 \u0440\u0430\u0437, \u044d\u0442\u043e\u0442 \u0444\u043b\u0430\u0433 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e 15-\u043e\u043c \u0441\u0438\u043c\u0432\u043e\u043b\u0435 \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u043f\u0430\u0440\u0442\u0438\u0438, \u0442\u0430\u043a \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u043e \u043d\u0430\u043c \u0432\u0430\u0436\u043d\u043e \u0434\u043b\u044f \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u0430 \u0438\u0437 \u0442\u0435\u043a\u0443\u0449\u0435\u0439.<\/p>\n<p>  <\/p>\n<p>\u0412 \u0446\u0438\u043a\u043b\u0435 \u043c\u044b \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0438\u043d\u0442\u0440\u0438\u043d\u0441\u0438\u043a\u0430 _mm_load_si128 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0442\u0438\u043f\u0430 __m128i (\u0432 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0435 \u043e\u043d\u0430 \u0441\u0442\u0430\u043d\u0435\u0442 128-\u0431\u0438\u0442\u043d\u044b\u043c XMM-\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u043c).<\/p>\n<p>  <\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043c\u044b \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u043c \u0442\u0435\u0441\u0442\u044b \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u043d\u0430 \u0442\u043e \u0447\u0442\u043e \u043e\u043d\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u0440\u043e\u0431\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u0438\u043b\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u0430\u043c\u0438 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0430 \u0441\u0442\u0440\u043e\u043a\u0438. \u041d\u0430\u0448\u0430 \u0446\u0435\u043b\u044c \u2014 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c 16-\u0431\u0438\u0442\u043d\u044b\u0435 \u043c\u0430\u0441\u043a\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043a\u0430\u0436\u0434\u044b\u0439 \u0431\u0438\u0442 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u0432 128-\u0431\u0438\u0442\u043d\u043e\u043c \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0435. SSE-\u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0441 XMM-\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u043c\u0438, \u0438 \u0434\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e \u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c 16-\u0431\u0438\u0442\u043d\u0443\u044e \u043c\u0430\u0441\u043a\u0443 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0438\u043d\u0442\u0440\u0438\u043d\u0441\u0438\u043a _mm_movemask_epi8. \u042d\u0442\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f \u0434\u0435\u043b\u0430\u0435\u0442 \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u043e \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u2014 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043d\u0430 \u0432\u0445\u043e\u0434 128-\u0431\u0438\u0442\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e, \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u0443\u0435\u0442 \u0435\u0435 \u043a\u0430\u043a \u043c\u0430\u0441\u0441\u0438\u0432 \u0438\u0437 16 \u0431\u0430\u0439\u0442, \u0438 \u0432\u044b\u0434\u0430\u0435\u0442 16-\u0431\u0438\u0442\u043d\u0443\u044e \u043c\u0430\u0441\u043a\u0443, \u043a\u0430\u0436\u0434\u044b\u0439 \u0431\u0438\u0442 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0438\u0437 \u0441\u0442\u0430\u0440\u0448\u0435\u0433\u043e \u0431\u0438\u0442\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u0431\u0430\u0439\u0442\u0430 XMM-\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430.<\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0442\u0435\u0441\u0442\u0430 \u043d\u0430 \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0441\u0442\u0440\u043e\u043a\u0438 \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e _mm_cmpeq_epi8, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0431\u0430\u0439\u0442\u043d\u043e \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u0442 \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0438 \u0432\u044b\u0434\u0430\u0435\u0442 128-\u0431\u0438\u0442\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u043a\u0430\u0436\u0434\u044b\u0439 \u0431\u0430\u0439\u0442 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0438\u043c\u0435\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 0, \u0435\u0441\u043b\u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u0431\u0430\u0439\u0442\u044b \u043d\u0435\u0440\u0430\u0432\u043d\u044b, \u0438 255 \u0432 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435. \u041d\u0430 \u0432\u0445\u043e\u0434 \u043c\u044b \u043f\u043e\u0434\u0430\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0441 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c\u044b\u043c\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u0430\u043c\u0438 \u0438 128-\u0431\u0438\u0442\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e, \u043a\u0430\u0436\u0434\u044b\u0439 \u0431\u0430\u0439\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u0438\u043c\u0432\u043e\u043b \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0430 \u0441\u0442\u0440\u043e\u043a\u0438 (\u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0438\u043d\u0442\u0440\u0438\u043d\u0441\u0438\u043a _mm_set1_epi8).<\/p>\n<p>  <\/p>\n<p>\u0421 \u0442\u0435\u0441\u0442\u043e\u043c \u043d\u0430 \u043f\u0440\u043e\u0431\u0435\u043b\u044c\u043d\u044b\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u0432\u0441\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u0435\u0435. \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0442\u0435\u0441\u0442 \u0431\u043e\u043b\u044c\u0448\u0435\/\u043c\u0435\u043d\u044c\u0448\u0435 SSE \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0434 \u0437\u043d\u0430\u043a\u043e\u0432\u044b\u043c\u0438 \u0446\u0435\u043b\u044b\u043c\u0438 \u0447\u0438\u0441\u043b\u0430\u043c\u0438. \u042d\u0442\u043e \u0438 \u0434\u0435\u043b\u0430\u0435\u0442 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f _mm_cmplt_epi8 \u2014 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u0447\u0442\u043e \u0431\u0430\u0439\u0442\u044b \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u0441\u0442\u0440\u043e\u0433\u043e \u043c\u0435\u043d\u044c\u0448\u0435 \u0431\u0430\u0439\u0442\u043e\u0432 \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043c\u0430\u0441\u043a\u0443 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e _mm_cmpeq_epi8. \u041d\u043e \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u043b\u044e\u0431\u043e\u0439 \u0441\u0438\u043c\u0432\u043e\u043b, \u043a\u043e\u0434 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0440\u0430\u0432\u0435\u043d 128 \u0438 \u0432\u044b\u0448\u0435, \u0442\u0430\u043a\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430\u0437\u043e\u0432\u0435\u0442 \u043f\u0440\u043e\u0431\u0435\u043b\u044c\u043d\u044b\u043c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u043c\u0430\u0441\u043a\u0438\u0440\u0443\u0435\u043c \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 _mm_andnot_si128. \u041e\u043d\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043d\u0430 \u0432\u0445\u043e\u0434 \u0434\u0432\u0430 128-\u0431\u0438\u0442\u043d\u044b\u0445 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u043e\u0431\u0438\u0442\u043e\u0432\u043e\u0433\u043e &quot;\u0418&quot; \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u0438 \u0438\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0432\u043e\u0433\u043e. \u041c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0442\u0435\u043a\u0443\u0449\u0438\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u043a\u0430\u043a \u043f\u0435\u0440\u0432\u044b\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 _mm_cmplt_epi8 \u043a\u0430\u043a \u0432\u0442\u043e\u0440\u043e\u0439. \u0423 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0441 \u043a\u043e\u0434\u043e\u043c \u0431\u043e\u043b\u044c\u0448\u0435 128 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u0441\u0442\u0430\u0440\u0448\u0438\u0439 \u0431\u0438\u0442, \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0441\u0442\u0430\u0440\u0448\u0438\u0435 \u0431\u0438\u0442\u044b \u0431\u0443\u0434\u0443\u0442 \u043e\u0431\u043d\u0443\u043b\u0435\u043d\u044b \u2014 \u044d\u0442\u043e \u043a\u0430\u043a \u0440\u0430\u0437 \u0442\u043e, \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f movemask&#8217;\u0430.<\/p>\n<p>  <\/p>\n<p>\u0414\u0430\u043b\u044c\u0448\u0435 \u043c\u044b \u0443\u0436\u0435 \u043e\u043f\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u0441 \u0431\u0438\u0442\u043e\u0432\u044b\u043c\u0438 \u043c\u0430\u0441\u043a\u0430\u043c\u0438 \u0432 \u043e\u0431\u044b\u0447\u043d\u044b\u0445 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0445. \u0412\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c \u043c\u0430\u0441\u043a\u0443 was_space_mask, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f is_space_mask \u0438 \u0444\u043b\u0430\u0433 was_space, \u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u0443\u0435\u043c \u043c\u0430\u0441\u043a\u0438 \u0442\u0430\u043a \u0436\u0435, \u043a\u0430\u043a \u0432 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0440\u043d\u043e\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c __popcnt \u0447\u0442\u043e \u0431\u044b \u0443\u0437\u043d\u0430\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u0431\u0438\u0442, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0430\u043a\u043a\u0443\u043c\u0443\u043b\u0438\u0440\u0443\u0435\u043c \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442. \u0412 \u043a\u043e\u043d\u0446\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c was_space \u0444\u043b\u0430\u0433, \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u044f \u0435\u0433\u043e \u0432 \u0441\u0442\u0430\u0440\u0448\u0438\u0439 \u0431\u0438\u0442 \u043c\u0430\u0441\u043a\u0438.<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u0443\u0437\u043d\u0430\u0442\u044c \u043e\u0431 SIMD-\u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f\u0445 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b x86 \u043b\u0443\u0447\u0448\u0435 <a href=\"https:\/\/software.intel.com\/sites\/lan dingpage\/IntrinsicsGuide\/\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/p>\n<p>  <\/p>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">Words: 44774640; lines: 15000010; chars: 1871822228 Elapsed time: 165.704300ms<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 11 \u0440\u0430\u0437 \u0431\u044b\u0441\u0442\u0440\u0435\u0435! \u041d\u0435\u043f\u043b\u043e\u0445\u043e\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442.<\/p>\n<p>  <\/p>\n<h3 id=\"esche-simd-magiya\">\u0415\u0449\u0435 SIMD-\u043c\u0430\u0433\u0438\u044f<\/h3>\n<p>  <\/p>\n<p>\u041d\u043e, \u043a\u0430\u043a \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u0441\u044f \u0432 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u0439 \u043f\u043e\u0441\u043b\u043e\u0432\u0438\u0446\u0435, \u043c\u0435\u0436\u0434\u0443 SSE \u0438 AVX \u043f\u0435\u0440\u0435\u0440\u044b\u0432\u0447\u0438\u043a \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c 32 \u0441\u0438\u043c\u0432\u043e\u043b\u0430 \u0437\u0430 \u0440\u0430\u0437 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 AVX\/AVX2:<\/p>\n<p>  <\/p>\n<pre><code class=\"cpp\">void word_count_avx( unsigned char* const str, uint32_t size, stats&amp; result ) {     uint32_t lines = 1;     uint32_t words = 0;      bool was_space = false;      for ( uint32_t i = 0; i &lt; size; i += 32 )     {         _mm_prefetch( (char*)str + i + 32 * 64, _MM_HINT_NTA );          __m256i const c = _mm256_load_si256( (__m256i*)( str + i ) );         uint32_t is_newline_mask = _mm256_movemask_epi8(             _mm256_cmpeq_epi8( c, _mm256_set1_epi8( '\\n' ) )         );          uint32_t is_space_mask = _mm256_movemask_epi8(             _mm256_andnot_si256( c, _mm256_sub_epi8( c, _mm256_set1_epi8( ' ' + 1 ) ) )         );         uint32_t was_space_mask = ( was_space ? 1 : 0 ) | ( is_space_mask &lt;&lt; 1 );          lines += __popcnt( is_newline_mask );         words += __popcnt( is_space_mask &amp; ~was_space_mask );         was_space = is_space_mask &amp; 0x80000000;     }      words += !was_space ? 1 : 0;      result.char_count = size;     result.line_count = lines;     result.word_count = words; }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e, \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 SSE-\u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u043c \u0441\u043c\u044b\u0441\u043b\u043e\u0432\u044b\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u043d\u0435\u0442. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u044b \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 AVX\/AVX2, \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u0435\u043d \u0442\u0435\u043c, \u0447\u0442\u043e \u0431\u044b\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u044b \u0440\u0430\u043d\u0435\u0435. \u0418\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442 \u0432 \u0446\u0438\u043a\u043b\u0435 \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0435 16, \u0430 32, \u0438 \u043c\u0430\u0441\u043a\u0438 \u0442\u0435\u043f\u0435\u0440\u044c 32-\u0431\u0438\u0442\u043d\u044b\u0435.<\/p>\n<p>  <\/p>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">Words: 44774640; lines: 15000010; chars: 1871822228 Elapsed time: 109.606000ms<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0432 \u043f\u043e\u043b\u0442\u043e\u0440\u0430 \u0440\u0430\u0437\u0430 \u0431\u044b\u0441\u0442\u0440\u0435\u0435.<\/p>\n<p>  <\/p>\n<h3 id=\"prefetch\">Prefetch<\/h3>\n<p>  <\/p>\n<p>\u0412 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f\u0445, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u043e\u0431\u044a\u0435\u043c\u044b \u043f\u0430\u043c\u044f\u0442\u0438, \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u044f \u043d\u0435 \u0442\u0430\u043a \u0443\u0436 \u043c\u043d\u043e\u0433\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439, \u0438 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043f\u0430\u043c\u044f\u0442\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439, \u0441\u0442\u043e\u0438\u0442 \u0437\u0430\u0434\u0443\u043c\u0430\u0442\u044c\u0441\u044f \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0442\u0440\u0438\u043d\u0441\u0438\u043a _mm_prefetch. \u0414\u0430\u043d\u043d\u0430\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u0447\u0430\u0441\u0442\u043e\u043a \u043f\u0430\u043c\u044f\u0442\u0438, \u0438 \u0447\u0442\u043e \u043d\u0435\u043f\u043b\u043e\u0445\u043e \u0431\u044b \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0435\u0433\u043e \u0432 \u043a\u0435\u0448 (\u0442\u043e, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u0441\u0438\u043b\u044c\u043d\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043c\u043e\u0434\u0435\u043b\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430). \u0422\u0430\u043a \u0447\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043b \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0432\u0441\u0442\u0430\u0432\u043a\u0443 \u0432 AVX-\u0432\u0430\u0440\u0438\u0430\u043d\u0442:<\/p>\n<p>  <\/p>\n<pre><code class=\"cpp\">void word_count2( unsigned char* const str, uint32_t size, stats&amp; result ) {     \/\/ ..............      for ( uint32_t i = 0; i &lt; size; i += 32 )     {         _mm_prefetch( (char*)str + i + 32 * 64, _MM_HINT_NTA );          \/\/ ..............     }      \/\/ .............. }<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">Words: 44774640; lines: 15000010; chars: 1871822228 Elapsed time: 73.564900ms<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u0446\u0438\u043a\u043b\u0430 \u043c\u044b \u043f\u0440\u043e\u0441\u0438\u043c \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0432 \u043a\u0435\u0448 \u0443\u0447\u0430\u0441\u0442\u043e\u043a \u043f\u0430\u043c\u044f\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 64 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438. \u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043d\u0435\u0447\u0435\u0441\u0442\u043d\u0430\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u044f \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u0438\u043b \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u0434 \u0441\u0435\u0431\u044f; \u043d\u0430 \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430\u0445 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0434\u0430\u0436\u0435 \u0441\u043d\u0438\u0437\u0438\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c.<\/p>\n<p>  <\/p>\n<p>\u0412 \u044d\u0442\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u044f \u043f\u043e\u0434\u0443\u043c\u0430\u043b, \u0447\u0442\u043e \u043c\u044b \u0443\u0436\u0435 \u043d\u0430\u0432\u0435\u0440\u043d\u044f\u043a\u0430 \u043f\u043e\u0447\u0442\u0438 \u0447\u0442\u043e \u0443\u043f\u0438\u0440\u0430\u0435\u043c\u0441\u044f \u0432 \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u043d\u0443\u044e \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c RAM. \u0418 \u043f\u0440\u0430\u0432\u0434\u0430 \u2014 \u0435\u0441\u043b\u0438 \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432 \u0446\u0438\u043a\u043b\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440, \u0446\u0438\u043a\u043b \u043e\u0442\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0437\u0430 70ms. \u0422\u0430\u043a \u0447\u0442\u043e \u0441\u043c\u044b\u0441\u043b\u0430 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043b\u044c\u0448\u0435 \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u043d\u0435\u0442 <del>(\u0434\u0430 \u0438 \u0440\u0430\u043d\u044c\u0448\u0435 \u0435\u0433\u043e \u043d\u0435 \u0431\u044b\u043b\u043e)<\/del>.<\/p>\n<p>  <\/p>\n<h3 id=\"vyvody\">\u0412\u044b\u0432\u043e\u0434\u044b<\/h3>\n<p>  <\/p>\n<p>\u0418\u0442\u0430\u043a, \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0431\u044b\u043b\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0441\u043b\u043e\u0432\u0430 \u0432 \u0442\u0435\u043a\u0441\u0442\u0435. \u0414\u0440\u0443\u0433\u043e\u0439 \u0432\u043e\u043f\u0440\u043e\u0441, \u0441\u0442\u043e\u0438\u0442 \u043b\u0438 \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0431\u044b\u0441\u0442\u0440\u043e, \u0438\u043b\u0438 \u043b\u0443\u0447\u0448\u0435 \u0432\u0441\u0435 \u0442\u0430\u043a\u0438 \u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043d\u0430 \u043b\u044e\u0431\u044b\u0445 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u043f\u0440\u0438 \u0442\u043e\u043c \u0447\u0442\u043e \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e 1.8 Gb \u0442\u0435\u043a\u0441\u0442\u0430 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043b\u0438\u0441\u044c \u0437\u0430 10 \u0441\u0435\u043a\u0443\u043d\u0434.<\/p>\n<p>  <\/p>\n<p>\u0412 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u0441\u0442\u0430\u0442\u044c\u044f \u0431\u044b\u043b\u0430 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0439, \u0438 \u043a\u0442\u043e-\u0442\u043e \u0441\u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0447\u0435\u0440\u043f\u043d\u0443\u0442\u044c \u0434\u043b\u044f \u0441\u0435\u0431\u044f \u0447\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u043d\u043e\u0432\u043e\u0435.<\/p>\n<p>  <\/p>\n<p>\u0412\u0435\u0441\u0435\u043b\u044b\u0445 \u0445\u043e\u043b\u0438\u0432\u0430\u0440\u043e\u0432!<\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/489898\/\"> https:\/\/habr.com\/ru\/post\/489898\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/489898\/\">\n<p>\u0412\u0441\u0435\u043c \u0434\u043e\u0431\u0440\u044b\u0439 \u0434\u0435\u043d\u044c.<\/p>\n<p>  <\/p>\n<p>\u041d\u0435\u0434\u0430\u0432\u043d\u043e \u043d\u0430 \u0425\u0430\u0431\u0440\u0435 \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u0441\u0442\u0430\u0442\u044c\u044f <a href=\"https:\/\/habr.com\/ru\/post\/489136\">\u041f\u043e\u0431\u0435\u0436\u0434\u0430\u044f C \u0434\u0432\u0430\u0434\u0446\u0430\u0442\u044c\u044e \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438 Haskell: \u043f\u0438\u0448\u0435\u043c \u0441\u0432\u043e\u0439 wc<\/a> \u043e\u0442 <a href=\"https:\/\/habr.com\/ru\/users\/0xd34df00d\/\">@0xd34df00d<\/a>. \u0410\u0432\u0442\u043e\u0440, \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0439 \u0441\u0432\u043e\u0435\u0439 \u0441\u0438\u043c\u043f\u0430\u0442\u0438\u0435\u0439 \u043a \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e, \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b \u043d\u0430 \u0425\u0430\u0441\u043a\u0435\u043b\u0435 \u0430\u043d\u0430\u043b\u043e\u0433 \u0443\u0442\u0438\u043b\u0438\u0442\u044b <i>wc<\/i>, \u0438 \u043f\u043e\u0434\u0432\u0435\u0440\u0433 \u0435\u0433\u043e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438, \u043f\u043e\u043b\u0443\u0447\u0438\u0432 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439 \u0431\u043e\u043b\u0435\u0435 \u0447\u0435\u043c \u0432 7 \u0440\u0430\u0437 \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u044e\u043d\u0438\u043a\u0441\u043e\u0432\u043e\u0439 \u0443\u0442\u0438\u043b\u0438\u0442\u044b.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-299227","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/299227","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=299227"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/299227\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=299227"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=299227"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=299227"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}