{"id":377858,"date":"2024-06-03T03:00:10","date_gmt":"2024-06-03T03:00:10","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=377858"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=377858","title":{"rendered":"<span>\u041a\u0440\u0430\u0442\u043a\u043e\u0435 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u0438<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/9e8\/c85\/d1e\/9e8c85d1ef0279a936eba96f884976b9.png\" alt=\"\u041f\u043e\u043f\u0440\u043e\u0441\u0438\u043b DALL-E \u043d\u0430\u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430, \u0432\u044b\u0431\u0438\u0440\u0430\u044e\u0449\u0435\u0433\u043e \u0441\u0435\u043a\u0443\u043d\u0434\u043e\u043c\u0435\u0440. \u0412\u043e\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 )\" title=\"\u041f\u043e\u043f\u0440\u043e\u0441\u0438\u043b DALL-E \u043d\u0430\u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430, \u0432\u044b\u0431\u0438\u0440\u0430\u044e\u0449\u0435\u0433\u043e \u0441\u0435\u043a\u0443\u043d\u0434\u043e\u043c\u0435\u0440. \u0412\u043e\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 )\" width=\"974\" height=\"974\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/9e8\/c85\/d1e\/9e8c85d1ef0279a936eba96f884976b9.png\"\/><\/p>\n<div><figcaption>\u041f\u043e\u043f\u0440\u043e\u0441\u0438\u043b DALL-E \u043d\u0430\u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430, \u0432\u044b\u0431\u0438\u0440\u0430\u044e\u0449\u0435\u0433\u043e \u0441\u0435\u043a\u0443\u043d\u0434\u043e\u043c\u0435\u0440. \u0412\u043e\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 )<\/figcaption><\/div>\n<\/figure>\n<p>\u0420\u0435\u0448\u0438\u043b \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u0432\u043e\u044e \u0441\u0442\u0430\u0440\u0443\u044e \u043a\u0440\u043e\u0445\u043e\u0442\u043d\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u0447\u043a\u0443 \u0434\u043b\u044f\u00a0\u0442\u0430\u0439\u043c\u0438\u043d\u0433\u0430 \u043a\u043e\u0434\u0430. \u0418\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0435 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0445 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u042b\u0445 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u0432 \u0432 \u043d\u0435\u0439 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b\u043e\u0441\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e: \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 RDTSC \u043f\u0440\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 MSC \u0434\u043b\u044f x86 \u0438 gettimeofday \u043f\u0440\u0438 \u0441\u0431\u043e\u0440\u043a\u0435 GCC \u043f\u043e\u0434 Linux. IMHO, \u043d\u0430 \u0441\u0435\u0433\u043e\u0434\u043d\u044f\u0448\u043d\u0438\u0439 \u0434\u0435\u043d\u044c \u044d\u0442\u043e \u043d\u0435 \u0441\u0430\u043c\u044b\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b, \u0438 \u0437\u0430\u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0431\u043e\u043b\u0435\u0435 \u0442\u043e\u0447\u043d\u043e\u0435 \u0438 \u043b\u0451\u0433\u043a\u043e\u0435. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0431\u044b\u043b\u0438 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u044b \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c\u0438 \u044d\u0442\u0438\u0445 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0439 \u0438 \u0434\u0435\u043b\u044e\u0441\u044c \u0441 \u0432\u0430\u043c\u0438 (\u0432\u0434\u0440\u0443\u0433 \u043a\u043e\u043c\u0443 \u0442\u043e\u0436\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e).<\/p>\n<p>\u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u043d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430 \u043e\u0434\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u0435 \u0441 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043e\u043c i7-6700K@4.00GHz, \u043d\u043e \u043f\u043e\u0434 \u0434\u0432\u0443\u043c\u044f \u041e\u0421: Win10 22H2 \u0438 Ubuntu 22.04. \u041f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u044b \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u043b\u0438\u0441\u044c \u0438 \u043d\u0430 \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u0430\u0448\u0438\u043d\u0430\u0445 (\u0432\u0441\u0435\u0433\u043e 8 \u0448\u0442\u0443\u043a \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0434\u0432\u0430 Raspberry Pi: 1B+ \u0438 4B), \u043d\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u043d\u0435 \u0441\u0442\u0430\u043b, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0435. <u>\u0412\u0441\u0435 \u0447\u0438\u0441\u043b\u0430 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u0437\u0430\u043c\u0435\u0440\u0435\u043d\u044b \u043d\u0430 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439 \u0432\u044b\u0448\u0435 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u0435!<\/u><\/p>\n<p>\u0412 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u043d\u0438\u0436\u0435 \u0432\u0441\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u044b \u0432 \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u043a\u0443\u043d\u0434\u0430\u0445. Discreteness &#8212; \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u0438\u0440\u043e\u0441\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0438\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 (\u043e\u0447\u0435\u043d\u044c \u0433\u0440\u0443\u0431\u043e \u0433\u043e\u0432\u043e\u0440\u044f \u044d\u0442\u043e \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f), Duration &#8212; \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0437\u043e\u0432\u0430 \u0441\u0430\u043c\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 (overhead), One tick &#8212; \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0435\u0434\u0438\u043d\u0438\u0446\u044b \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f, Type &#8212; \u0442\u0438\u043f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 (\u043c\u0438\u0440\u043e\u0432\u043e\u0435 \u0432\u0440\u0435\u043c\u044f, \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u0442\u043e\u043a\u0430 \u0438\u043b\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430).<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/bfb\/e27\/44b\/bfbe2744b9177271e03a8beb1dae1e44.png\" width=\"1076\" height=\"1064\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/bfb\/e27\/44b\/bfbe2744b9177271e03a8beb1dae1e44.png\"\/><\/figure>\n<h4>\u041a\u0440\u0430\u0442\u043a\u0438\u0435 (\u0435\u0441\u043b\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f) \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u044f \u043f\u043e \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u0438:<\/h4>\n<ol>\n<li>\n<p><strong>clock()<\/strong> [\u042189] \u2013 \u041e\u043f\u0438\u0441\u044b\u0432\u0430\u044e \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0437 \u0443\u0432\u0430\u0436\u0435\u043d\u0438\u044f \u043a \u044d\u0442\u043e\u0439 \u0434\u0440\u0435\u0432\u043d\u0435\u0439\u0448\u0435\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u0435\u0449\u0451 \u0432 \u043f\u0435\u0440\u0432\u043e\u0439 \u0440\u0435\u0434\u0430\u043a\u0446\u0438\u0438 ANSI C \u0438 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0430\u043b\u0430\u0441\u044c \u043a\u0430\u043a \u0440\u0430\u0437 \u0434\u043b\u044f \u0442\u043e\u0447\u043d\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u0432 \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u041f\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u00ab<u>processor time<\/u> used by the program so far\u00bb \u043d\u043e \u043f\u043e \u0438\u0441\u0442\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c \u0435\u0451 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0443 Microsoft \u043d\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0443 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u00abthe <u>elapsed time<\/u> since the CRT initialization at the start of the process\u00bb. \u042d\u0442\u043e \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u0435 \u043d\u0435 \u0438\u043c\u0435\u043b\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u043e\u0434\u043d\u043e-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043d\u044b\u0445 \u041e\u0421 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 MS DOS) \u043d\u043e \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0438\u0430\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u043c\u043d\u043e\u0433\u043e\u0437\u0430\u0434\u0430\u0447\u043d\u044b\u0445 \u041e\u0421. \u0422\u0430\u043a \u0447\u0442\u043e \u0434\u043b\u044f \u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u044d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043d\u0435 \u0433\u043e\u0434\u0438\u0442\u0441\u044f. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u00ab\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u0430\u044f\u00bb \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 Linux \u043d\u0443 \u043e\u043e\u043e\u043e\u0447\u0435\u043d\u044c \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0430\u044f (\u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0437\u043e\u0432\u0430 960ns(!!!) \u043f\u0440\u043e\u0442\u0438\u0432 36ns \u043d\u0430 Windows). \u0412\u043e\u043e\u0431\u0449\u0435 \u0432\u0441\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u0435 \u0432\u0440\u0435\u043c\u044f, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0435 \u0441 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u043c \u0438\u043b\u0438 \u043f\u043e\u0442\u043e\u043a\u043e\u043c, \u043e\u0447\u0435\u043d\u044c \u043d\u0435\u0441\u043f\u0435\u0448\u043d\u044b, \u0432\u0438\u0434\u0438\u043c\u043e \u0438\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u0432 \u0440\u0435\u0436\u0438\u043c \u044f\u0434\u0440\u0430, \u0430 \u044d\u0442\u043e, \u043a\u0430\u043a \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0434\u043e\u0440\u043e\u0433\u0430\u044f. \u0414\u0438\u0441\u043a\u0440\u0435\u0442\u043d\u043e\u0441\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u0442\u043e\u0436\u0435 \u043d\u0435 \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u0430 (1ms \u0432 Windows \u0438 1\u00b5s \u0432 POSIX).<\/p>\n<\/li>\n<li>\n<p><strong>timespec_get()<\/strong> [C11] \u2013 \u041f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0432 \u043d\u0430\u043d\u043e\u0441\u0435\u043a\u0443\u043d\u0434\u0430\u0445. \u041d\u043e \u043d\u0435 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043f\u0443\u0442\u0430\u0442\u044c \u0435\u0434\u0438\u043d\u0438\u0446\u044b \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f \u0438 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u2013 \u0432 Windows \u044d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0438\u043c\u0435\u0435\u0442 \u0434\u0438\u0441\u043a\u0440\u0435\u0442\u043d\u043e\u0441\u0442\u044c 100ns \u0430 \u0432 Linux \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0436\u0435\u043b\u0435\u0437\u0430 (22ns \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u0435 \u0438 1,1\u00b5s(!!!) \u043d\u0430 Raspberry Pi 1B+). \u0422\u043e, \u0447\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f, \u0434\u0435\u043b\u0430\u0435\u0442 \u0435\u0451 \u043d\u0435 \u043c\u043e\u043d\u043e\u0442\u043e\u043d\u043d\u043e\u0439 \u2013 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043c\u043e\u0436\u0435\u0442 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0440\u0435\u043c\u044f (\u0434\u0430\u0436\u0435 \u043d\u0430\u0437\u0430\u0434).<\/p>\n<\/li>\n<li>\n<p><strong>std::chrono<\/strong> [C++11] &#8212; \u0444\u0443\u043d\u043a\u0446\u0438\u0438 now() \u043a\u043b\u0430\u0441\u0441\u043e\u0432 high_resolution_clock \u0438 steady_clock \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043b\u0451\u0433\u043a\u0438\u0435 \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u0432 \u043d\u0430\u043d\u043e\u0441\u0435\u043a\u0443\u043d\u0434\u0430\u0445 (\u0441\u043c. \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 \u043a timespec_get()). \u0412 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0435 \u043e\u0433\u043e\u0432\u0430\u0440\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e high_resolution_clock \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430\u0438\u0442\u043e\u0447\u043d\u0435\u0439\u0448\u0435\u0435 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u043d\u043e \u0435\u0441\u0442\u044c \u043d\u044e\u0430\u043d\u0441, \u044d\u0442\u0438 \u0447\u0430\u0441\u044b \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u043d\u044b \u0431\u044b\u0442\u044c steady. \u0412 Linux high_resolution_clock \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0438\u043d\u043e\u043d\u0438\u043c\u043e\u043c \u0434\u043b\u044f system_clock \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043a\u043e\u0440\u0440\u0435\u043a\u0446\u0438\u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u043a\u0430\u043a \u0438 timespec_get, \u043a\u043e\u0440\u043e\u0447\u0435 \u0433\u043e\u0432\u043e\u0440\u044f, \u0432 Linux \u0432\u0440\u0435\u043c\u044f \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u043d\u043e\u0435 high_resolution_clock \u043c\u043e\u0436\u0435\u0442 \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0442\u044c\u0441\u044f! \u0417\u0430\u0447\u0435\u043c \u0442\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u043d\u0435 \u0437\u043d\u0430\u044e. \u0412 Windows \u044d\u0442\u043e\u0442 \u043a\u043b\u0430\u0441\u0441 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0438\u043d\u043e\u043d\u0438\u043c\u043e\u043c steady_clock \u0438 \u043f\u043e\u0442\u043e\u043c\u0443 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043c\u043e\u043d\u043e\u0442\u043e\u043d\u043d\u044b\u043c. \u041d\u0430 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430\u0445 \u0434\u0438\u0441\u043a\u0440\u0435\u0442\u043d\u043e\u0441\u0442\u044c \u0438 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u0441\u0435\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 std::chrono \u043e\u043a\u0430\u0437\u0430\u043b\u0438\u0441\u044c \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b \u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442 timespec_get(). \u0412 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u044f\u043c\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c steady_clock \u0438 \u043d\u0435 \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0441 high_resolution_clock.<\/p>\n<\/li>\n<li>\n<p><strong>gettimeofday()<\/strong> [POSIX] \u2013 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u0432 \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u043a\u0443\u043d\u0434\u0430\u0445. \u041d\u0430 \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0435\u0439 &#8212; \u00abPOSIX.1-2008 marks gettimeofday() as obsolete, recommending the use of clock_gettime() instead\u00bb. \u0423\u043f\u043e\u043c\u0438\u043d\u0430\u044e \u0435\u0451 \u043b\u0438\u0448\u044c \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043e\u043d\u0430 \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u0438\u0437 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0430.<\/p>\n<\/li>\n<li>\n<p><strong>clock_gettime(CLOCK_MONOTONIC_RAW)<\/strong> [Linux] \u2013 \u0432\u0438\u0434\u0438\u043c\u043e \u043b\u0443\u0447\u0448\u0438\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0434\u043b\u044f \u0442\u0430\u0439\u043c\u0438\u043d\u0433\u0430 \u0432 LinuxAPI. \u0422\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0438 \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043e\u043a\u043e\u043b\u043e 22ns.<\/p>\n<\/li>\n<li>\n<p><strong>QueryPerformanceCounter()<\/strong> [WinAPI] \u2013 \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u0438 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0438\u0437 WinAPI. \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043c\u043e\u043d\u043e\u0442\u043e\u043d\u043d\u0430, \u0434\u0438\u0441\u043a\u0440\u0435\u0442\u043d\u043e\u0441\u0442\u044c \u2013 100ns (\u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u043f\u043e\u043c\u0435\u043d\u044c\u0448\u0435), \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f &#8212; 13ns(!).<\/p>\n<\/li>\n<li>\n<p><strong>RDTSC\/RDTSCP<\/strong> &#8212; \u0434\u043b\u044f \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u0432 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430 x86 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430\u0445 \u0447\u0430\u0441\u0442\u043e \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e\u0442 \u044d\u0442\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438. \u041d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u0435 \u043e\u043d\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0437\u0430 6,4\/9,2ns (\u043f\u0440\u0438 \u0447\u0430\u0441\u0442\u043e\u0442\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 4,0GHz \u044d\u0442\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e 26\/37 \u0442\u0430\u043a\u0442\u043e\u0432). TSC \u043f\u0440\u0438\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c: \u0430) \u0441\u0447\u0451\u0442\u0447\u0438\u043a \u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0441 \u043d\u0435\u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e\u0439 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c\u044e; \u0431) \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u044f\u0434\u0440\u0430\u0445 \u043e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043d\u0435 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u044b; \u0432) \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u043c\u043e\u0436\u0435\u0442 \u043f\u0435\u0440\u0435\u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0438\u0442\u044c \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u0447\u0451\u0442\u0447\u0438\u043a\u0430.<\/p>\n<\/li>\n<li>\n<p><strong>cntvct_el0<\/strong> &#8212; Counter-timer Virtual Count \u0440\u0435\u0433\u0438\u0441\u0442\u0440 ARM \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430. \u0412 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u043d\u0435 \u043f\u043e\u043f\u0430\u043b, \u043d\u043e \u0431\u044b\u043b \u0438\u0441\u043f\u044b\u0442\u0430\u043d \u043d\u0430 RPi 4B. \u0414\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435 \u0438 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0434\u0438\u0441\u043a\u0440\u0435\u0442\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0432\u043d\u0443\u044e 18,5ns \u043f\u0440\u0438 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0432\u044b\u0437\u043e\u0432\u0430 5.0ns (\u0434\u043b\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 \u0441 \u0447\u0430\u0441\u0442\u043e\u0442\u043e\u0439 1.8GHz \u044d\u0442\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e 33 \u0438 9 \u0442\u0430\u043a\u0442\u043e\u0432). \u041f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u0434\u0430 \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430:<\/p>\n<p><code>inline uint64_t vi_get_cntvct()<br \/> {uint64_t result;<br \/> __asm__ __volatile__(\"mrs %0, cntvct_el0\" : \"=r\"(result));<br \/>return result;<br \/> }<\/code><\/p>\n<\/li>\n<\/ol>\n<h4>\u0427\u0443\u0442\u044c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043f\u0440\u043e \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044b\u0435 \u0432\u044b\u0448\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b TSC \u043d\u0430 x86 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0435<\/h4>\n<p>\u041f\u0435\u0440\u0432\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 &#8212; \u0443\u0436\u0435 \u043d\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430: <em>\u00abFor Pentium 4 processors, Intel Xeon processors &lt;\u2026>; for Intel Core Solo and Intel Core Duo processors &lt;&#8230;>; for the Intel Xeon processor 5100 series and Intel Core 2 Duo processors &lt;&#8230;>; for Intel Core 2 and Intel Xeon processors &lt;\u2026>; for Intel Atom processors &lt;\u2026>: the <\/em><strong><em><u>time-stamp counter increments at a constant rate<\/u><\/em><\/strong><em>\u201d<\/em><strong> <\/strong>(<em>Intel\u00ae 64 and IA-32 Architectures Software Developer\u2019s Manual Combined Volumes: 1, 2A, 2B, 2C, 2D, 3A, 3B, 3C, 3D, and 4. <\/em><strong><em>Vol. 3B. P.18-42<\/em><\/strong>)<\/p>\n<p>\u0412\u0442\u043e\u0440\u0443\u044e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e\u0442 \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u0434\u0432\u0443\u043c\u044f \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438:<\/p>\n<ul>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0447\u0435\u0442\u0430\u043d\u0438\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 RDTSCP \u0438 LFANCE: <em>\u00abThe RDTSCP instruction is not a serializing instruction, but it does wait until all previous instructions have executed &lt;\u2026> If software requires RDTSCP to be executed prior to execution of any subsequent instruction (including any memory accesses), it can execute LFENCE immediately after RDTSCP\u00bb<\/em> (<em>Intel\u00ae 64 and IA-32 Architectures Software Developer\u2019s Manual Combined Volumes: 1, 2A, 2B, 2C, 2D, 3A, 3B, 3C, 3D, and 4. Vol. 2B. P.4-553<\/em>). \u0415\u0441\u043b\u0438 \u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043f\u043e\u043d\u044f\u043b, \u0442\u043e \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u043d\u0435\u0447\u0442\u043e \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0435 \u043a\u043e\u0434\u0443 \u043d\u0438\u0436\u0435 (\u043f\u0440\u0438 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u044d\u0442\u0438 intrinsic \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0438 \u0432 GCC, \u0438 \u0432 MSC):<\/p>\n<p><code>inline uint64_t vi_get_tsc()<br \/>{uint32_t aux; \/\/ \u0411\u0443\u0434\u0435\u0442 \u0443\u0434\u0430\u043b\u0451\u043d \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0442\u043e\u0440\u043e\u043c<br \/>const uint64_t result = __rdtscp(&amp;aux);<br \/>_mm_lfence();<br \/>return result;<br \/>}<\/code><\/p>\n<\/li>\n<li>\n<p>\u0414\u0440\u0443\u0433\u043e\u0439 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0439 \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435 \u0441\u043e\u0432\u0435\u0442 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u0432 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0435 \u2013 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c CPUID:<\/p>\n<p><code>inline uint64_t vi_get_tsc()<br \/>{int32_t cpuInfo[4]; \/\/ \u0411\u0443\u0434\u0435\u0442 \u0443\u0434\u0430\u043b\u0451\u043d \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0442\u043e\u0440\u043e\u043c<br \/>uint32_t aux;<br \/>const uint64_t result = __rdtscp(&amp;aux);<br \/>__cpuid(cpuInfo, 0);<br \/>return result;<br \/>}<\/code><\/p>\n<\/li>\n<\/ul>\n<p><strong>\u041d\u043e!<\/strong> \u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 CPUID \u043f\u043e\u0434 Windows \u044f \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441 \u043d\u0435\u043f\u043e\u043d\u044f\u0442\u043d\u044b\u043c \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435\u043c. \u0423\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0435 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 32ns \u0434\u043b\u044f &lt;ASM>::RDTSCP+CPUID \u0431\u044b\u043b\u0438 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u044b \u0432 Safe mode. \u0412 \u043e\u0431\u044b\u0447\u043d\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435 Windows \u0432\u044b\u0437\u043e\u0432 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 CPUID \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u043b \u0432\u0440\u0435\u043c\u0435\u043d\u0430 \u0434\u043e <strong>350ns(!!!)<\/strong>. \u041f\u043e\u0445\u043e\u0436\u0435, \u0447\u0442\u043e \u043d\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u043d\u044b\u0445 \u043c\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u0430\u0445 \u0441 Windows \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f CPUID \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b\u0430\u0441\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e. \u041d\u0430\u0432\u0435\u0440\u043d\u043e \u044d\u0442\u043e \u0438\u0437-\u0437\u0430 \u043a\u0430\u043a\u043e\u0433\u043e-\u0442\u043e \u041f\u041e, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043d\u0430 \u0432\u0441\u0435\u0445 \u043c\u043e\u0438\u0445 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0430\u0445. \u0420\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u043f\u043e\u043a\u0430 \u043d\u0435 \u0441\u0442\u0430\u043b, \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u043a\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442 \u044d\u0442\u043e \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445.<\/p>\n<h4>\u041a\u0430\u043a \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u043b\u0438\u0441\u044c \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f<\/h4>\n<p>\u0423\u0442\u0438\u043b\u0438\u0442\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u043b\u0430\u0441\u044c \u0441 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u043e\u043c ABOVENORMAL (nice -n -5). \u041f\u0435\u0440\u0435\u0434 \u0432\u0441\u0435\u043c\u0438 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f\u043c\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u043f\u0440\u043e\u0433\u0440\u0435\u0432\u0430\u043b\u0441\u044f \u043f\u043e\u043b\u0441\u0435\u043a\u0443\u043d\u0434\u044b \u043f\u0440\u0438 100% \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u0440\u0430\u0431\u043e\u0447\u0435\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430. \u041f\u043e\u0442\u043e\u043c \u0432\u044b\u0437\u0432\u0430\u043b\u0430\u0441\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044f <strong>std::this_thread::yield()<\/strong> \u044d\u0442\u043e \u043d\u0430\u0438\u0432\u043d\u0430\u044f \u043f\u043e\u043f\u044b\u0442\u043a\u0430 \u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0442\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u0435\u0441\u043b\u0438 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0435 \u0443\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u043e\u0434\u0438\u043d \u043a\u0432\u0430\u043d\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 (\u043a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u044d\u0442\u043e \u043d\u0435 \u0437\u0430\u0449\u0438\u0449\u0430\u0435\u0442 \u043e\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0439). \u0414\u0430\u043b\u0435\u0435 5 \u0440\u0430\u0437 \u0432\u044b\u0437\u044b\u0432\u0430\u043b\u0438\u0441\u044c \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0432 \u0442\u0435\u0441\u0442\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0434\u0430\u043d\u043d\u044b\u0435, \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0438\u0437 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0439 \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u0434\u0433\u0440\u0443\u0437\u043a\u0438 \u0432 \u043a\u044d\u0448 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430. \u0417\u0430\u043c\u0435\u0440\u044b \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u043b\u0438\u0441\u044c \u0434\u0432\u0430\u0436\u0434\u044b \u0441 \u0440\u0430\u0437\u043d\u044b\u043c \u0447\u0438\u0441\u043b\u043e\u043c \u043f\u043e\u0432\u0442\u043e\u0440\u043e\u0432 \u0434\u043b\u044f \u0443\u0447\u0451\u0442\u0430 \u043d\u0430\u043a\u043b\u0430\u0434\u043d\u044b\u0445 \u0440\u0430\u0441\u0445\u043e\u0434\u043e\u0432. \u041d\u0430\u043a\u043e\u043d\u0435\u0446 \u0432\u0441\u0435 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043b\u0438\u0441\u044c \u043f\u043e 20 \u0440\u0430\u0437 \u0438 \u0437\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0431\u0440\u0430\u043b\u043e\u0441\u044c \u043c\u0435\u0434\u0438\u0430\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 (\u043e\u0431\u044b\u0447\u043d\u043e \u043e\u043d\u043e \u043e\u0447\u0435\u043d\u044c \u0431\u043b\u0438\u0437\u043a\u043e \u043a \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u043c\u0443).<\/p>\n<h3>\u0418\u0442\u043e\u0433\u0438<\/h3>\n<p>\u041d\u0438\u043a\u0430\u043a\u0438\u0445 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0439 \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u043d\u0435 \u0431\u044b\u043b\u043e (\u0438 \u043d\u0435 \u043e\u0436\u0438\u0434\u0430\u043b\u043e\u0441\u044c). \u0414\u043b\u044f \u0441\u0435\u0431\u044f \u0441\u0434\u0435\u043b\u0430\u043b \u0432\u044b\u0431\u043e\u0440 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c (\u043d\u0430\u0434\u0435\u044e\u0441\u044c \u043d\u0430 \u043a\u0440\u0438\u0442\u0438\u043a\u0443 \u043f\u0440\u043e\u0444\u0438):<\/p>\n<pre><code class=\"cpp\">#include &lt;stdint.h>  #ifdef _MSC_VER #include &lt;intrin.h> #pragma intrinsic(__rdtscp, _mm_lfence) #elif defined(__GNUC__) #   include &lt;x86intrin.h> #endif  #ifdef __cplusplus extern \"C\" { #endif  #if defined(_M_X64) || defined(_M_AMD64) || defined(__x86_64__) || defined(__amd64__) \/\/ MSC or GCC on Intel static inline uint64_t vi_tmGetTicks(void) {uint32_t _; \/\/ \u0431\u0443\u0434\u0435\u0442 \u0443\u0434\u0430\u043b\u0451\u043d \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0442\u043e\u0440\u043e\u043c const uint64_t result = __rdtscp(&amp;_); _mm_lfence(); return result; } #elif __ARM_ARCH >= 8 \/\/ ARMv8 (RaspberryPi4) static inline uint64_t vi_tmGetTicks(void) {uint64_t result; __asm__ __volatile__(\"mrs %0, cntvct_el0\" : \"=r\"(result)); return result; } #elif defined(_WIN32) \/\/ Windows on other platforms. static inline uint64_t vi_tmGetTicks(void) {LARGE_INTEGER cnt; QueryPerformanceCounter(&amp;cnt); return cnt.QuadPart; } #elif defined(__linux__) \/\/ Linux on other platforms static inline uint64_t vi_tmGetTicks(void) {struct timespec ts; clock_gettime(CLOCK_MONOTONIC_RAW, &amp;ts); return 1000000000ULL * ts.tv_sec + ts.tv_nsec; } #else #error \"You need to define function(s) for your OS and CPU\" #endif  #ifdef cplusplus } \/\/ extern \"C\" { #endif<\/code><\/pre>\n<p>\u0411\u0443\u0434\u0443 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u0435\u043d \u0437\u0430 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u0438\u0432\u043d\u044b\u0435 \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u044f.<\/p>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e, \u0447\u0442\u043e \u0434\u043e\u0447\u0438\u0442\u0430\u043b\u0438 )<\/p>\n<p>P.S.<br \/>\u0415\u0449\u0451 \u043f\u0430\u0440\u0430 \u043b\u043e\u0433\u043e\u0432 \u0441 \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u0430\u0448\u0438\u043d:<\/p>\n<details class=\"spoiler\">\n<summary>i3-4005U CPU @ 1.70GHz<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cpp\">Start: 2024.05.05 20:11:01 Processor: Intel(R) Core(TM) i3-4005U CPU @ 1.70GHz  Collecting function properties... Done (872.0s )  Measured properties of time functions (median of 5 measurements): Name:............................................ Discreteness:    +\/- Duration:    +\/- One tick:    +\/-   Type: vvvvvv                                                                                                           &lt;WIN>::timeGetTime():............................        15.6ms   0.5%    25.0ns   1.7%     1.0ms   0.1%    Wall &lt;WIN>::timeGetSystemTime():......................        15.6ms   0.5%    29.0ns   0.8%     1.0ms   0.1%    Wall &lt;WIN>::_time64():................................         1.0s    0.0%    18.0ns  21.0%     1.0s    0.0%    Wall &lt;WIN>::_time32():................................         1.0s    0.0%    18.0ns   4.6%     1.0s    0.0%    Wall &lt;WIN>::QueryUnbiasedInterruptTimePrecise():......       100.0ns   0.0%    42.0ns   0.0%   100.0ns   0.0%    Wall &lt;WIN>::QueryUnbiasedInterruptTime():.............        15.6ms   0.0%    15.0ns  38.0%   100.0ns   0.0%    Wall &lt;WIN>::QueryThreadCycleTime():...................       880.0ns   0.2%   910.0ns   0.3%   590.0ps   0.0%  Thread &lt;WIN>::QueryProcessCycleTime():..................         8.5us  10.0%     8.2us   4.6%   590.0ps   0.0% Process &lt;WIN>::QueryPerformanceCounter():................       100.0ns   0.0%    28.0ns   0.0%   100.0ns   0.0%    Wall &lt;WIN>::QueryInterruptTimePrecise():..............       100.0ns   0.2%    41.0ns   3.6%   100.0ns   0.0%    Wall &lt;WIN>::QueryInterruptTime():.....................        15.6ms   0.0%     2.1ns  86.0%   100.0ns   0.0%    Wall &lt;WIN>::NtQuerySystemTime():......................        15.6ms   0.0%     4.4ns  23.0%   100.0ns   0.0%    Wall &lt;WIN>::GetTickCount64():.........................        15.6ms   0.0%    14.0ns  57.0%     1.0ms   0.1%    Wall &lt;WIN>::GetTickCount():...........................        15.6ms   0.5%    13.0ns  42.0%     1.0ms   0.1%    Wall &lt;WIN>::GetThreadTimes():.........................        15.6ms   0.0%   890.0ns   0.3%   100.0ns   1.2%  Thread &lt;WIN>::GetSystemTimes() K+U:.....................         8.6ms   7.5%     3.2us   1.4%    25.0ns   0.9%    Wall &lt;WIN>::GetSystemTimePreciseAsFileTime():.........       100.0ns   0.0%    48.0ns   0.0%   100.0ns   0.0%    Wall &lt;WIN>::GetSystemTimeAsFileTime():................        15.6ms   0.0%    14.0ns  14.0%   100.0ns   0.0%    Wall &lt;WIN>::GetSystemTime():..........................        15.6ms   0.0%   130.0ns   0.3%   100.0ns   0.1%    Wall &lt;WIN>::GetProcessTimes():........................        15.6ms   0.0%     1.0us   1.8%   100.0ns   0.0% Process &lt;WIN>::GetLocalTime():...........................        15.6ms   0.0%   190.0ns   0.3%   100.0ns   0.1%    Wall &lt;C>  ::timespec_get(TIME_UTC):...................       100.0ns   0.0%    73.0ns   3.8%     1.0ns   0.0%    Wall &lt;C>  ::time():...................................         1.0s    0.0%    18.0ns   4.3%     1.0s    0.0%    Wall &lt;C>  ::clock():..................................         1.0ms   0.0%    85.0ns   4.1%     1.0ms   0.0%    Wall &lt;C++>::system_clock::now():......................       100.0ns   0.0%    45.0ns   0.0%   100.0ns   0.0%    Wall &lt;C++>::steady_clock::now():......................       100.0ns   0.0%    36.0ns   0.0%     1.0ns   0.0%    Wall &lt;C++>::high_resolution_clock::now():.............       100.0ns   0.0%    36.0ns   0.0%     1.0ns   0.0%    Wall &lt;BST>::cpu_timer.elapsed() wall:.................         1.1us   0.1%     1.1us   3.0%     1.0ns   0.0%    Wall &lt;BST>::cpu_timer.elapsed() user + system:........        15.6ms   0.0%     1.1us   0.1%     1.0ns   0.0% Process &lt;ASM>::RDTSC_INTRINSIC:..........................        14.2ns   0.0%    14.0ns   0.0%   590.0ps   0.0%    Wall &lt;ASM>::RDTSC_ASM:................................        14.2ns   1.0%    14.0ns   0.0%   590.0ps   0.0%    Wall &lt;ASM>::RDTSCP_INTRINSIC:.........................        19.5ns   0.0%    18.0ns   0.0%   590.0ps   0.0%    Wall &lt;ASM>::RDTSCP_ASM:...............................        21.2ns   1.1%    19.0ns   0.0%   590.0ps   0.0%    Wall &lt;ASM>::RDTSCP+LFENCE_INTRINSIC:..................        32.6ns   0.0%    31.0ns   0.0%   590.0ps   0.0%    Wall &lt;ASM>::RDTSCP+LFENCE_ASM:........................        33.6ns   0.0%    33.0ns   0.0%   590.0ps   0.0%    Wall &lt;ASM>::RDTSCP+CPUID_INTRINSIC:...................        79.0ns   0.0%    79.0ns   1.2%   590.0ps   0.0%    Wall &lt;ASM>::RDTSCP+CPUID_ASM:.........................        80.1ns   0.0%    79.0ns   0.1%   590.0ps   0.0%    Wall &lt;ASM>::MFENCE+LFENCE+RDTSC_INTRINSIC:............        36.8ns   0.0%    39.0ns   0.0%   590.0ps   0.0%    Wall &lt;ASM>::MFENCE+LFENCE+RDTSC_ASM:..................        40.7ns   0.0%    40.0ns   0.0%   590.0ps   0.0%    Wall &lt;ASM>::LFENCE+RDTSC_INTRINSIC:...................        21.1ns   2.2%    19.0ns   5.4%   590.0ps   0.0%    Wall &lt;ASM>::LFENCE+RDTSC_ASM:.........................        22.4ns   0.0%    21.0ns   0.0%   590.0ps   0.0%    Wall &lt;ASM>::CPUID+RDTSC_INTRINSIC:....................        64.9ns   0.7%    67.0ns   0.0%   590.0ps   0.0%    Wall &lt;ASM>::CPUID+RDTSC_ASM:..........................        68.4ns   0.0%    67.0ns   0.0%   590.0ps   0.0%    Wall   Notes: The std::chrono::system_clock::is_steady:          false; The std::chrono::steady_clock::is_steady:          true; The std::chrono::high_resolution_clock::is_steady: true; The std::chrono::system_clock::duration:          100.0ns; The std::chrono::steady_clock::duration:            1.0ns; The std::chrono::high_resolution_clock::duration:   1.0ns; The number of clock vi_tmGetTicks per second 'CLOCKS_PER_SEC': 1'000 (what is equivalent to 1.0ms) Frequency of the performance counter 'QueryPerformanceFrequency()': 10'000'000 (what is equivalent to 100.0ns); The timer resolution 'NtQueryTimerResolution()': 15.6ms. (from 0.5 to 15.6ms); The timer device to determine its resolution 'timeGetDevCaps()': from 1 to 1'000'000ms.; Periodic time adjustments 'GetSystemTimeAdjustment()': TimeAdjustment = 15.6ms; TimeIncrement = 15.6ms; TimeAdjustmentDisabled = true;  Time expend: 00:14:33 <\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>Cortex-A72 1.8GHz (Raspberry Pi 4B)<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cpp\">Start: 2024.05.29 16:08:46 Model name:                           Cortex-A72 CPU max MHz:                          1800.0000 CPU min MHz:                          600.0000 Computer: 'RaspberryPi4'  Collecting function properties... Done (1.5ks)  Measured properties of time functions (median of 20 measurements): Name:............................................ Discreteness:    +\/- Duration:    +\/- One tick:    +\/-   Type: vvvvvv                                                                                                           &lt;LNX>::times(tms):...............................        10.0ms   0.0%   870.0ns   0.5%    10.0ms   0.8% Process &lt;LNX>::times(nullptr):...........................        10.0ms   0.0%   400.0ns   0.0%    10.0ms   0.0%    Wall &lt;LNX>::gettimeofday():...........................         1.0us   0.0%    44.0ns   0.3%     1.0us   0.0%    Wall &lt;LNX>::getrusage(RUSAGE_THREAD):.................         4.0ms   0.0%   680.0ns   0.3%     1.0us   0.0%  Thread &lt;LNX>::getrusage(RUSAGE_SELF):...................         1.1us   0.4%     1.1us   0.2%     1.0us   0.0% Process &lt;LNX>::clock_gettime(CLOCK_THREAD_CPUTIME_ID):...       747.0ns   0.9%   750.0ns   0.3%     1.0ns   0.0%  Thread &lt;LNX>::clock_gettime(CLOCK_TAI):.................        48.3ns   0.1%    45.0ns   0.1%     1.0ns   0.0%    Wall &lt;LNX>::clock_gettime(CLOCK_REALTIME_COARSE):.....         4.0ms   0.0%    18.0ns   0.2%     1.0ns   0.0%    Wall &lt;LNX>::clock_gettime(CLOCK_REALTIME):............        48.3ns   0.1%    45.0ns   0.3%     1.0ns   0.0%    Wall &lt;LNX>::clock_gettime(CLOCK_PROCESS_CPUTIME_ID):..       773.0ns   0.9%   790.0ns   0.5%     1.0ns   0.0% Process &lt;LNX>::clock_gettime(CLOCK_MONOTONIC_RAW):.......        48.5ns   7.0%    46.0ns  12.0%     1.0ns   0.0%    Wall &lt;LNX>::clock_gettime(CLOCK_MONOTONIC_COARSE):....         4.0ms   0.0%    18.0ns   0.2%     1.0ns   0.0%    Wall &lt;LNX>::clock_gettime(CLOCK_MONOTONIC):...........        48.3ns   0.2%    45.0ns   0.2%     1.0ns   0.0%    Wall &lt;LNX>::clock_gettime(CLOCK_BOOTTIME):............        48.3ns   0.2%    45.0ns   2.8%     1.0ns   0.0%    Wall &lt;C>  ::timespec_get(TIME_UTC):...................        47.3ns   9.5%    44.0ns  12.0%     1.0ns   0.0%    Wall &lt;C>  ::time():...................................         1.0s    0.0%    22.0ns   2.0%     1.0s    0.0%    Wall &lt;C>  ::clock():..................................         1.0us   0.0%   780.0ns   0.3%     1.0us   0.0% Process &lt;C++>::system_clock::now():......................        46.7ns  12.0%    44.0ns   7.6%     1.0ns   0.0%    Wall &lt;C++>::steady_clock::now():......................        46.7ns  13.0%    43.0ns   0.6%     1.0ns   0.0%    Wall &lt;C++>::high_resolution_clock::now():.............        46.7ns  12.0%    43.0ns   1.3%     1.0ns   0.0%    Wall &lt;ASM>::MRS:......................................        18.9ns   0.2%     5.0ns   0.7%    19.0ns   0.0%    Wall   Notes: The std::chrono::system_clock::is_steady:          false; The std::chrono::steady_clock::is_steady:          true; The std::chrono::high_resolution_clock::is_steady: false; The std::chrono::system_clock::duration:            1.0ns; The std::chrono::steady_clock::duration:            1.0ns; The std::chrono::high_resolution_clock::duration:   1.0ns; The number of clock vi_tmGetTicks per second 'CLOCKS_PER_SEC': 1'000'000 (what is equivalent to 1.0us) The number of clock vi_tmGetTicks per second 'sysconf(_SC_CLK_TCK)': 100 (10ms); Resolution (precision) 'clock_getres(CLOCK_REALTIME)': 1.0ns; Resolution (precision) 'clock_getres(CLOCK_MONOTONIC)': 1.0ns; Resolution (precision) 'clock_getres(CLOCK_PROCESS_CPUTIME_ID)': 1.0ns; Resolution (precision) 'clock_getres(CLOCK_THREAD_CPUTIME_ID)': 1.0ns;  Time expend: 00:25:14<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \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\/articles\/818965\/\"> https:\/\/habr.com\/ru\/articles\/818965\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\">\n<div><figcaption>\u041f\u043e\u043f\u0440\u043e\u0441\u0438\u043b DALL-E \u043d\u0430\u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430, \u0432\u044b\u0431\u0438\u0440\u0430\u044e\u0449\u0435\u0433\u043e \u0441\u0435\u043a\u0443\u043d\u0434\u043e\u043c\u0435\u0440. \u0412\u043e\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 )<\/figcaption><\/div>\n<\/figure>\n<p>\u0420\u0435\u0448\u0438\u043b \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u0432\u043e\u044e \u0441\u0442\u0430\u0440\u0443\u044e \u043a\u0440\u043e\u0445\u043e\u0442\u043d\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u0447\u043a\u0443 \u0434\u043b\u044f\u00a0\u0442\u0430\u0439\u043c\u0438\u043d\u0433\u0430 \u043a\u043e\u0434\u0430. \u0418\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0435 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0445 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u042b\u0445 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u0432 \u0432 \u043d\u0435\u0439 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b\u043e\u0441\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e: \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 RDTSC \u043f\u0440\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 MSC \u0434\u043b\u044f x86 \u0438 gettimeofday \u043f\u0440\u0438 \u0441\u0431\u043e\u0440\u043a\u0435 GCC \u043f\u043e\u0434 Linux. IMHO, \u043d\u0430 \u0441\u0435\u0433\u043e\u0434\u043d\u044f\u0448\u043d\u0438\u0439 \u0434\u0435\u043d\u044c \u044d\u0442\u043e \u043d\u0435 \u0441\u0430\u043c\u044b\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b, \u0438 \u0437\u0430\u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0431\u043e\u043b\u0435\u0435 \u0442\u043e\u0447\u043d\u043e\u0435 \u0438 \u043b\u0451\u0433\u043a\u043e\u0435. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0431\u044b\u043b\u0438 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u044b \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c\u0438 \u044d\u0442\u0438\u0445 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0439 \u0438 \u0434\u0435\u043b\u044e\u0441\u044c \u0441 \u0432\u0430\u043c\u0438 (\u0432\u0434\u0440\u0443\u0433 \u043a\u043e\u043c\u0443 \u0442\u043e\u0436\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e).<\/p>\n<p>\u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u043d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430 \u043e\u0434\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u0435 \u0441 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043e\u043c i7-6700K@4.00GHz, \u043d\u043e \u043f\u043e\u0434 \u0434\u0432\u0443\u043c\u044f \u041e\u0421: Win10 22H2 \u0438 Ubuntu 22.04. \u041f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u044b \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u043b\u0438\u0441\u044c \u0438 \u043d\u0430 \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u0430\u0448\u0438\u043d\u0430\u0445 (\u0432\u0441\u0435\u0433\u043e 8 \u0448\u0442\u0443\u043a \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0434\u0432\u0430 Raspberry Pi: 1B+ \u0438 4B), \u043d\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u043d\u0435 \u0441\u0442\u0430\u043b, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0435. <u>\u0412\u0441\u0435 \u0447\u0438\u0441\u043b\u0430 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u0437\u0430\u043c\u0435\u0440\u0435\u043d\u044b \u043d\u0430 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439 \u0432\u044b\u0448\u0435 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u0435!<\/u><\/p>\n<p>\u0412 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u043d\u0438\u0436\u0435 \u0432\u0441\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u044b \u0432 \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u043a\u0443\u043d\u0434\u0430\u0445. Discreteness &#8212; \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u0438\u0440\u043e\u0441\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0438\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 (\u043e\u0447\u0435\u043d\u044c \u0433\u0440\u0443\u0431\u043e \u0433\u043e\u0432\u043e\u0440\u044f \u044d\u0442\u043e \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f), Duration &#8212; \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0437\u043e\u0432\u0430 \u0441\u0430\u043c\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 (overhead), One tick &#8212; \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0435\u0434\u0438\u043d\u0438\u0446\u044b \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f, Type &#8212; \u0442\u0438\u043f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 (\u043c\u0438\u0440\u043e\u0432\u043e\u0435 \u0432\u0440\u0435\u043c\u044f, \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u0442\u043e\u043a\u0430 \u0438\u043b\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430).<\/p>\n<figure class=\"full-width\"><\/figure>\n<h4>\u041a\u0440\u0430\u0442\u043a\u0438\u0435 (\u0435\u0441\u043b\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f) \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u044f \u043f\u043e \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u0438:<\/h4>\n<ol>\n<li>\n<p><strong>clock()<\/strong> [\u042189] \u2013 \u041e\u043f\u0438\u0441\u044b\u0432\u0430\u044e \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0437 \u0443\u0432\u0430\u0436\u0435\u043d\u0438\u044f \u043a \u044d\u0442\u043e\u0439 \u0434\u0440\u0435\u0432\u043d\u0435\u0439\u0448\u0435\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u0435\u0449\u0451 \u0432 \u043f\u0435\u0440\u0432\u043e\u0439 \u0440\u0435\u0434\u0430\u043a\u0446\u0438\u0438 ANSI C \u0438 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0430\u043b\u0430\u0441\u044c \u043a\u0430\u043a \u0440\u0430\u0437 \u0434\u043b\u044f \u0442\u043e\u0447\u043d\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u0432 \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u041f\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u00ab<u>processor time<\/u> used by the program so far\u00bb \u043d\u043e \u043f\u043e \u0438\u0441\u0442\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c \u0435\u0451 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0443 Microsoft \u043d\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0443 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u00abthe <u>elapsed time<\/u> since the CRT initialization at the start of the process\u00bb. \u042d\u0442\u043e \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u0435 \u043d\u0435 \u0438\u043c\u0435\u043b\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u043e\u0434\u043d\u043e-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043d\u044b\u0445 \u041e\u0421 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 MS DOS) \u043d\u043e \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0438\u0430\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u043c\u043d\u043e\u0433\u043e\u0437\u0430\u0434\u0430\u0447\u043d\u044b\u0445 \u041e\u0421. \u0422\u0430\u043a \u0447\u0442\u043e \u0434\u043b\u044f \u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u044d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043d\u0435 \u0433\u043e\u0434\u0438\u0442\u0441\u044f. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u00ab\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u0430\u044f\u00bb \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 Linux \u043d\u0443 \u043e\u043e\u043e\u043e\u0447\u0435\u043d\u044c \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0430\u044f (\u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0437\u043e\u0432\u0430 960ns(!!!) \u043f\u0440\u043e\u0442\u0438\u0432 36ns \u043d\u0430 Windows). \u0412\u043e\u043e\u0431\u0449\u0435 \u0432\u0441\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u0435 \u0432\u0440\u0435\u043c\u044f, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0435 \u0441 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u043c \u0438\u043b\u0438 \u043f\u043e\u0442\u043e\u043a\u043e\u043c, \u043e\u0447\u0435\u043d\u044c \u043d\u0435\u0441\u043f\u0435\u0448\u043d\u044b, \u0432\u0438\u0434\u0438\u043c\u043e \u0438\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u0432 \u0440\u0435\u0436\u0438\u043c \u044f\u0434\u0440\u0430, \u0430 \u044d\u0442\u043e, \u043a\u0430\u043a \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0434\u043e\u0440\u043e\u0433\u0430\u044f. \u0414\u0438\u0441\u043a\u0440\u0435\u0442\u043d\u043e\u0441\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u0442\u043e\u0436\u0435 \u043d\u0435 \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u0430 (1ms \u0432 Windows \u0438 1\u00b5s \u0432 POSIX).<\/p>\n<\/li>\n<li>\n<p><strong>timespec_get()<\/strong> [C11] \u2013 \u041f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0432 \u043d\u0430\u043d\u043e\u0441\u0435\u043a\u0443\u043d\u0434\u0430\u0445. \u041d\u043e \u043d\u0435 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043f\u0443\u0442\u0430\u0442\u044c \u0435\u0434\u0438\u043d\u0438\u0446\u044b \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f \u0438 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u2013 \u0432 Windows \u044d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0438\u043c\u0435\u0435\u0442 \u0434\u0438\u0441\u043a\u0440\u0435\u0442\u043d\u043e\u0441\u0442\u044c 100ns \u0430 \u0432 Linux \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0436\u0435\u043b\u0435\u0437\u0430 (22ns \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u0435 \u0438 1,1\u00b5s(!!!) \u043d\u0430 Raspberry Pi 1B+). \u0422\u043e, \u0447\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f, \u0434\u0435\u043b\u0430\u0435\u0442 \u0435\u0451 \u043d\u0435 \u043c\u043e\u043d\u043e\u0442\u043e\u043d\u043d\u043e\u0439 \u2013 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043c\u043e\u0436\u0435\u0442 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0440\u0435\u043c\u044f (\u0434\u0430\u0436\u0435 \u043d\u0430\u0437\u0430\u0434).<\/p>\n<\/li>\n<li>\n<p><strong>std::chrono<\/strong> [C++11] &#8212; \u0444\u0443\u043d\u043a\u0446\u0438\u0438 now() \u043a\u043b\u0430\u0441\u0441\u043e\u0432 high_resolution_clock \u0438 steady_clock \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043b\u0451\u0433\u043a\u0438\u0435 \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u0432 \u043d\u0430\u043d\u043e\u0441\u0435\u043a\u0443\u043d\u0434\u0430\u0445 (\u0441\u043c. \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 \u043a timespec_get()). \u0412 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0435 \u043e\u0433\u043e\u0432\u0430\u0440\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e high_resolution_clock \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430\u0438\u0442\u043e\u0447\u043d\u0435\u0439\u0448\u0435\u0435 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u043d\u043e \u0435\u0441\u0442\u044c \u043d\u044e\u0430\u043d\u0441, \u044d\u0442\u0438 \u0447\u0430\u0441\u044b \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u043d\u044b \u0431\u044b\u0442\u044c steady. \u0412 Linux high_resolution_clock \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0438\u043d\u043e\u043d\u0438\u043c\u043e\u043c \u0434\u043b\u044f system_clock \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043a\u043e\u0440\u0440\u0435\u043a\u0446\u0438\u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u043a\u0430\u043a \u0438 timespec_get, \u043a\u043e\u0440\u043e\u0447\u0435 \u0433\u043e\u0432\u043e\u0440\u044f, \u0432 Linux \u0432\u0440\u0435\u043c\u044f \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u043d\u043e\u0435 high_resolution_clock \u043c\u043e\u0436\u0435\u0442 \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0442\u044c\u0441\u044f! \u0417\u0430\u0447\u0435\u043c \u0442\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u043d\u0435 \u0437\u043d\u0430\u044e. \u0412 Windows \u044d\u0442\u043e\u0442 \u043a\u043b\u0430\u0441\u0441 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0438\u043d\u043e\u043d\u0438\u043c\u043e\u043c steady_clock \u0438 \u043f\u043e\u0442\u043e\u043c\u0443 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043c\u043e\u043d\u043e\u0442\u043e\u043d\u043d\u044b\u043c. \u041d\u0430 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430\u0445 \u0434\u0438\u0441\u043a\u0440\u0435\u0442\u043d\u043e\u0441\u0442\u044c \u0438 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u0441\u0435\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 std::chrono \u043e\u043a\u0430\u0437\u0430\u043b\u0438\u0441\u044c \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b \u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442 timespec_get(). \u0412 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u044f\u043c\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c steady_clock \u0438 \u043d\u0435 \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0441 high_resolution_clock.<\/p>\n<\/li>\n<li>\n<p><strong>gettimeofday()<\/strong> [POSIX] \u2013 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u0432 \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u043a\u0443\u043d\u0434\u0430\u0445. \u041d\u0430 \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0435\u0439 &#8212; \u00abPOSIX.1-2008 marks gettimeofday() as obsolete, recommending the use of clock_gettime() instead\u00bb. \u0423\u043f\u043e\u043c\u0438\u043d\u0430\u044e \u0435\u0451 \u043b\u0438\u0448\u044c \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043e\u043d\u0430 \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u0438\u0437 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0430.<\/p>\n<\/li>\n<li>\n<p><strong>clock_gettime(CLOCK_MONOTONIC_RAW)<\/strong> [Linux] \u2013 \u0432\u0438\u0434\u0438\u043c\u043e \u043b\u0443\u0447\u0448\u0438\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0434\u043b\u044f \u0442\u0430\u0439\u043c\u0438\u043d\u0433\u0430 \u0432 LinuxAPI. \u0422\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0438 \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043e\u043a\u043e\u043b\u043e 22ns.<\/p>\n<\/li>\n<li>\n<p><strong>QueryPerformanceCounter()<\/strong> [WinAPI] \u2013 \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u0438 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0438\u0437 WinAPI. \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043c\u043e\u043d\u043e\u0442\u043e\u043d\u043d\u0430, \u0434\u0438\u0441\u043a\u0440\u0435\u0442\u043d\u043e\u0441\u0442\u044c \u2013 100ns (\u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u043f\u043e\u043c\u0435\u043d\u044c\u0448\u0435), \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f &#8212; 13ns(!).<\/p>\n<\/li>\n<li>\n<p><strong>RDTSC\/RDTSCP<\/strong> &#8212; \u0434\u043b\u044f \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u0432 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430 x86 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430\u0445 \u0447\u0430\u0441\u0442\u043e \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e\u0442 \u044d\u0442\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438. \u041d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u0435 \u043e\u043d\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0437\u0430 6,4\/9,2ns (\u043f\u0440\u0438 \u0447\u0430\u0441\u0442\u043e\u0442\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 4,0GHz \u044d\u0442\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e 26\/37 \u0442\u0430\u043a\u0442\u043e\u0432). TSC \u043f\u0440\u0438\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c: \u0430) \u0441\u0447\u0451\u0442\u0447\u0438\u043a \u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0441 \u043d\u0435\u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e\u0439 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c\u044e; \u0431) \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u044f\u0434\u0440\u0430\u0445 \u043e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043d\u0435 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u044b; \u0432) \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u043c\u043e\u0436\u0435\u0442 \u043f\u0435\u0440\u0435\u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0438\u0442\u044c \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u0447\u0451\u0442\u0447\u0438\u043a\u0430.<\/p>\n<\/li>\n<li>\n<p><strong>cntvct_el0<\/strong> &#8212; Counter-timer Virtual Count \u0440\u0435\u0433\u0438\u0441\u0442\u0440 ARM \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430. \u0412 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u043d\u0435 \u043f\u043e\u043f\u0430\u043b, \u043d\u043e \u0431\u044b\u043b \u0438\u0441\u043f\u044b\u0442\u0430\u043d \u043d\u0430 RPi 4B. \u0414\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435 \u0438 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0434\u0438\u0441\u043a\u0440\u0435\u0442\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0432\u043d\u0443\u044e 18,5ns \u043f\u0440\u0438 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0432\u044b\u0437\u043e\u0432\u0430 5.0ns (\u0434\u043b\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 \u0441 \u0447\u0430\u0441\u0442\u043e\u0442\u043e\u0439 1.8GHz \u044d\u0442\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e 33 \u0438 9 \u0442\u0430\u043a\u0442\u043e\u0432). \u041f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u0434\u0430 \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430:<\/p>\n<p><code>inline uint64_t vi_get_cntvct()<br \/> {uint64_t result;<br \/> __asm__ __volatile__(\"mrs %0, cntvct_el0\" : \"=r\"(result));<br \/>return result;<br \/> }<\/code><\/p>\n<\/li>\n<\/ol>\n<h4>\u0427\u0443\u0442\u044c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043f\u0440\u043e \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044b\u0435 \u0432\u044b\u0448\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b TSC \u043d\u0430 x86 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0435<\/h4>\n<p>\u041f\u0435\u0440\u0432\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 &#8212; \u0443\u0436\u0435 \u043d\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430: <em>\u00abFor Pentium 4 processors, Intel Xeon processors &lt;\u2026>; for Intel Core Solo and Intel Core Duo processors &lt;&#8230;>; for the Intel Xeon processor 5100 series and Intel Core 2 Duo processors &lt;&#8230;>; for Intel Core 2 and Intel Xeon processors &lt;\u2026>; for Intel Atom processors &lt;\u2026>: the <\/em><strong><em><u>time-stamp counter increments at a constant rate<\/u><\/em><\/strong><em>\u201d<\/em><strong> <\/strong>(<em>Intel\u00ae 64 and IA-32 Architectures Software Developer\u2019s Manual Combined Volumes: 1, 2A, 2B, 2C, 2D, 3A, 3B, 3C, 3D, and 4. <\/em><strong><em>Vol. 3B. P.18-42<\/em><\/strong>)<\/p>\n<p>\u0412\u0442\u043e\u0440\u0443\u044e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e\u0442 \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u0434\u0432\u0443\u043c\u044f \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438:<\/p>\n<ul>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0447\u0435\u0442\u0430\u043d\u0438\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 RDTSCP \u0438 LFANCE: <em>\u00abThe RDTSCP instruction is not a serializing instruction, but it does wait until all previous instructions have executed &lt;\u2026> If software requires RDTSCP to be executed prior to execution of any subsequent instruction (including any memory accesses), it can execute LFENCE immediately after RDTSCP\u00bb<\/em> (<em>Intel\u00ae 64 and IA-32 Architectures Software Developer\u2019s Manual Combined Volumes: 1, 2A, 2B, 2C, 2D, 3A, 3B, 3C, 3D, and 4. Vol. 2B. P.4-553<\/em>). \u0415\u0441\u043b\u0438 \u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043f\u043e\u043d\u044f\u043b, \u0442\u043e \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u043d\u0435\u0447\u0442\u043e \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0435 \u043a\u043e\u0434\u0443 \u043d\u0438\u0436\u0435 (\u043f\u0440\u0438 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u044d\u0442\u0438 intrinsic \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0438 \u0432 GCC, \u0438 \u0432 MSC):<\/p>\n<p><code>inline uint64_t vi_get_tsc()<br \/>{uint32_t aux; \/\/ \u0411\u0443\u0434\u0435\u0442 \u0443\u0434\u0430\u043b\u0451\u043d \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0442\u043e\u0440\u043e\u043c<br \/>const uint64_t result = __rdtscp(&amp;aux);<br \/>_mm_lfence();<br \/>return result;<br \/>}<\/code><\/p>\n<\/li>\n<li>\n<p>\u0414\u0440\u0443\u0433\u043e\u0439 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0439 \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435 \u0441\u043e\u0432\u0435\u0442 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u0432 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0435 \u2013 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c CPUID:<\/p>\n<p><code>inline uint64_t vi_get_tsc()<br \/>{int32_t cpuInfo[4]; \/\/ \u0411\u0443\u0434\u0435\u0442 \u0443\u0434\u0430\u043b\u0451\u043d \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0442\u043e\u0440\u043e\u043c<br \/>uint32_t aux;<br \/>const uint64_t result = __rdtscp(&amp;aux);<br \/>__cpuid(cpuInfo, 0);<br \/>return result;<br \/>}<\/code><\/p>\n<\/li>\n<\/ul>\n<p><strong>\u041d\u043e!<\/strong> \u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 CPUID \u043f\u043e\u0434 Windows \u044f \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441 \u043d\u0435\u043f\u043e\u043d\u044f\u0442\u043d\u044b\u043c \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435\u043c. \u0423\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0435 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 32ns \u0434\u043b\u044f &lt;ASM>::RDTSCP+CPUID \u0431\u044b\u043b\u0438 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u044b \u0432 Safe mode. \u0412 \u043e\u0431\u044b\u0447\u043d\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435 Windows \u0432\u044b\u0437\u043e\u0432 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 CPUID \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u043b \u0432\u0440\u0435\u043c\u0435\u043d\u0430 \u0434\u043e <strong>350ns(!!!)<\/strong>. \u041f\u043e\u0445\u043e\u0436\u0435, \u0447\u0442\u043e \u043d\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u043d\u044b\u0445 \u043c\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u0430\u0445 \u0441 Windows \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f CPUID \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b\u0430\u0441\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e. \u041d\u0430\u0432\u0435\u0440\u043d\u043e \u044d\u0442\u043e \u0438\u0437-\u0437\u0430 \u043a\u0430\u043a\u043e\u0433\u043e-\u0442\u043e \u041f\u041e, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043d\u0430 \u0432\u0441\u0435\u0445 \u043c\u043e\u0438\u0445 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0430\u0445. \u0420\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u043f\u043e\u043a\u0430 \u043d\u0435 \u0441\u0442\u0430\u043b, \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u043a\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442 \u044d\u0442\u043e \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445.<\/p>\n<h4>\u041a\u0430\u043a \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u043b\u0438\u0441\u044c \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f<\/h4>\n<p>\u0423\u0442\u0438\u043b\u0438\u0442\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u043b\u0430\u0441\u044c \u0441 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u043e\u043c ABOVENORMAL (nice -n -5). \u041f\u0435\u0440\u0435\u0434 \u0432\u0441\u0435\u043c\u0438 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f\u043c\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u043f\u0440\u043e\u0433\u0440\u0435\u0432\u0430\u043b\u0441\u044f \u043f\u043e\u043b\u0441\u0435\u043a\u0443\u043d\u0434\u044b \u043f\u0440\u0438 100% \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u0440\u0430\u0431\u043e\u0447\u0435\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430. \u041f\u043e\u0442\u043e\u043c \u0432\u044b\u0437\u0432\u0430\u043b\u0430\u0441\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044f <strong>std::this_thread::yield()<\/strong> \u044d\u0442\u043e \u043d\u0430\u0438\u0432\u043d\u0430\u044f \u043f\u043e\u043f\u044b\u0442\u043a\u0430 \u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0442\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u0435\u0441\u043b\u0438 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0435 \u0443\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u043e\u0434\u0438\u043d \u043a\u0432\u0430\u043d\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 (\u043a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u044d\u0442\u043e \u043d\u0435 \u0437\u0430\u0449\u0438\u0449\u0430\u0435\u0442 \u043e\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0439). \u0414\u0430\u043b\u0435\u0435 5 \u0440\u0430\u0437 \u0432\u044b\u0437\u044b\u0432\u0430\u043b\u0438\u0441\u044c \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0432 \u0442\u0435\u0441\u0442\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0434\u0430\u043d\u043d\u044b\u0435, \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0438\u0437 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0439 \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u0434\u0433\u0440\u0443\u0437\u043a\u0438 \u0432 \u043a\u044d\u0448 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430. \u0417\u0430\u043c\u0435\u0440\u044b \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u043b\u0438\u0441\u044c \u0434\u0432\u0430\u0436\u0434\u044b \u0441 \u0440\u0430\u0437\u043d\u044b\u043c \u0447\u0438\u0441\u043b\u043e\u043c \u043f\u043e\u0432\u0442\u043e\u0440\u043e\u0432 \u0434\u043b\u044f \u0443\u0447\u0451\u0442\u0430 \u043d\u0430\u043a\u043b\u0430\u0434\u043d\u044b\u0445 \u0440\u0430\u0441\u0445\u043e\u0434\u043e\u0432. \u041d\u0430\u043a\u043e\u043d\u0435\u0446 \u0432\u0441\u0435 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043b\u0438\u0441\u044c \u043f\u043e 20 \u0440\u0430\u0437 \u0438 \u0437\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0431\u0440\u0430\u043b\u043e\u0441\u044c \u043c\u0435\u0434\u0438\u0430\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 (\u043e\u0431\u044b\u0447\u043d\u043e \u043e\u043d\u043e \u043e\u0447\u0435\u043d\u044c \u0431\u043b\u0438\u0437\u043a\u043e \u043a \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u043c\u0443).<\/p>\n<h3>\u0418\u0442\u043e\u0433\u0438<\/h3>\n<p>\u041d\u0438\u043a\u0430\u043a\u0438\u0445 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0439 \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u043d\u0435 \u0431\u044b\u043b\u043e (\u0438 \u043d\u0435 \u043e\u0436\u0438\u0434\u0430\u043b\u043e\u0441\u044c). \u0414\u043b\u044f \u0441\u0435\u0431\u044f \u0441\u0434\u0435\u043b\u0430\u043b \u0432\u044b\u0431\u043e\u0440 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c (\u043d\u0430\u0434\u0435\u044e\u0441\u044c \u043d\u0430 \u043a\u0440\u0438\u0442\u0438\u043a\u0443 \u043f\u0440\u043e\u0444\u0438):<\/p>\n<pre><code class=\"cpp\">#include &lt;stdint.h>  #ifdef _MSC_VER #include &lt;intrin.h> #pragma intrinsic(__rdtscp, _mm_lfence) #elif defined(__GNUC__) #   include &lt;x86intrin.h> #endif  #ifdef __cplusplus extern \"C\" { #endif  #if defined(_M_X64) || defined(_M_AMD64) || defined(__x86_64__) || defined(__amd64__) \/\/ MSC or GCC on Intel static inline uint64_t vi_tmGetTicks(void) {uint32_t _; \/\/ \u0431\u0443\u0434\u0435\u0442 \u0443\u0434\u0430\u043b\u0451\u043d \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0442\u043e\u0440\u043e\u043c const uint64_t result = __rdtscp(&amp;_); _mm_lfence(); return result; } #elif __ARM_ARCH >= 8 \/\/ ARMv8 (RaspberryPi4) static inline uint64_t vi_tmGetTicks(void) {uint64_t result; __asm__ __volatile__(\"mrs %0, cntvct_el0\" : \"=r\"(result)); return result; } #elif defined(_WIN32) \/\/ Windows on other platforms. static inline uint64_t vi_tmGetTicks(void) {LARGE_INTEGER cnt; QueryPerformanceCounter(&amp;cnt); return cnt.QuadPart; } #elif defined(__linux__) \/\/ Linux on other platforms static inline uint64_t vi_tmGetTicks(void) {struct timespec ts; clock_gettime(CLOCK_MONOTONIC_RAW, &amp;ts); return 1000000000ULL * ts.tv_sec + ts.tv_nsec; } #else #error \"You need to define function(s) for your OS and CPU\" #endif  #ifdef cplusplus } \/\/ extern \"C\" { #endif<\/code><\/pre>\n<p>\u0411\u0443\u0434\u0443 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u0435\u043d \u0437\u0430 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u0438\u0432\u043d\u044b\u0435 \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u044f.<\/p>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e, \u0447\u0442\u043e \u0434\u043e\u0447\u0438\u0442\u0430\u043b\u0438 )<\/p>\n<p>P.S.<br \/>\u0415\u0449\u0451 \u043f\u0430\u0440\u0430 \u043b\u043e\u0433\u043e\u0432 \u0441 \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u0430\u0448\u0438\u043d:<\/p>\n<details class=\"spoiler\">\n<summary>i3-4005U CPU @ 1.70GHz<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cpp\">Start: 2024.05.05 20:11:01 Processor: Intel(R) Core(TM) i3-4005U CPU @ 1.70GHz  Collecting function properties... Done (872.0s )  Measured properties of time functions (median of 5 measurements): Name:............................................ Discreteness:    +\/- Duration:    +\/- One tick:    +\/-   Type: vvvvvv                                                                                                           &lt;WIN>::timeGetTime():............................        15.6ms   0.5%    25.0ns   1.7%     1.0ms   0.1%    Wall &lt;WIN>::timeGetSystemTime():......................<\/code><\/pre>\n<\/div>\n<\/details>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\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-377858","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/377858","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=377858"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/377858\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=377858"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=377858"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=377858"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}