odin-blend2d

Odin bindings to Blend2D
Log | Files | Refs | README | LICENSE

asmjit_bench_codegen.cpp (2273B)


      1 // This file is part of AsmJit project <https://asmjit.com>
      2 //
      3 // See <asmjit/core.h> or LICENSE.md for license and copyright information
      4 // SPDX-License-Identifier: Zlib
      5 
      6 #include <asmjit/core.h>
      7 #include <stdio.h>
      8 #include <stdlib.h>
      9 #include <string.h>
     10 
     11 #include "../commons/asmjitutils.h"
     12 #include "../commons/cmdline.h"
     13 
     14 using namespace asmjit;
     15 
     16 static void print_app_info() noexcept {
     17   printf("AsmJit Benchmark CodeGen v%u.%u.%u [Arch=%s] [Mode=%s]\n\n",
     18     unsigned((ASMJIT_LIBRARY_VERSION >> 16)       ),
     19     unsigned((ASMJIT_LIBRARY_VERSION >>  8) & 0xFF),
     20     unsigned((ASMJIT_LIBRARY_VERSION      ) & 0xFF),
     21     asmjit_arch_as_string(Arch::kHost),
     22     asmjit_build_type()
     23   );
     24 }
     25 
     26 #if !defined(ASMJIT_NO_X86)
     27 void benchmark_x86_emitters(uint32_t num_iterations, bool test_x86, bool test_x64) noexcept;
     28 #endif
     29 
     30 #if !defined(ASMJIT_NO_AARCH64)
     31 void benchmark_aarch64_emitters(uint32_t num_iterations);
     32 #endif
     33 
     34 int main(int argc, char* argv[]) {
     35   CmdLine cmd_line(argc, argv);
     36   uint32_t num_iterations = 100000;
     37 
     38   print_app_info();
     39 
     40   printf("Usage:\n");
     41   printf("  --help         Show usage only\n");
     42   printf("  --quick        Decrease the number of iterations to make tests quicker\n");
     43   printf("  --arch=<ARCH>  Select architecture(s) to run ('all' by default)\n");
     44   printf("\n");
     45 
     46   printf("Architectures:\n");
     47 #if !defined(ASMJIT_NO_X86)
     48   printf("  --arch=x86     32-bit X86 architecture (X86)\n");
     49   printf("  --arch=x64     64-bit X86 architecture (X86_64)\n");
     50 #endif
     51 #if !defined(ASMJIT_NO_AARCH64)
     52   printf("  --arch=aarch64 64-bit ARM architecture (AArch64)\n");
     53 #endif
     54   printf("\n");
     55 
     56   if (cmd_line.has_arg("--help"))
     57     return 0;
     58 
     59   if (cmd_line.has_arg("--quick"))
     60     num_iterations = 1000;
     61 
     62   const char* arch = cmd_line.value_of("--arch", "all");
     63 
     64 #if !defined(ASMJIT_NO_X86)
     65   bool test_x86 = strcmp(arch, "all") == 0 || strcmp(arch, "x86") == 0;
     66   bool test_x64 = strcmp(arch, "all") == 0 || strcmp(arch, "x64") == 0;
     67 
     68   if (test_x86 || test_x64) {
     69     benchmark_x86_emitters(num_iterations, test_x86, test_x64);
     70   }
     71 #endif
     72 
     73 #if !defined(ASMJIT_NO_AARCH64)
     74   bool test_aarch64 = strcmp(arch, "all") == 0 || strcmp(arch, "aarch64") == 0;
     75 
     76   if (test_aarch64) {
     77     benchmark_aarch64_emitters(num_iterations);
     78   }
     79 #endif
     80 
     81   return 0;
     82 }