Skip to content

Instantly share code, notes, and snippets.

@sonOfRa
Last active December 17, 2019 17:05
Show Gist options
  • Save sonOfRa/a0a71115366d7e6750ef18bf33329d3c to your computer and use it in GitHub Desktop.
Save sonOfRa/a0a71115366d7e6750ef18bf33329d3c to your computer and use it in GitHub Desktop.
Boyer-Moore vs Naive substring search
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 60
model name : Intel(R) Core(TM) i7-4771 CPU @ 3.50GHz
stepping : 3
microcode : 0x27
cpu MHz : 2673.855
cache size : 8192 KB
physical id : 0
siblings : 8
core id : 0
cpu cores : 4
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm cpuid_fault invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt dtherm ida arat pln pts md_clear flush_l1d
bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs itlb_multihit
bogomips : 6999.91
clflush size : 64
cache_alignment : 64
address sizes : 39 bits physical, 48 bits virtual
power management:
Java 8:
openjdk version "1.8.0_232-ea"
OpenJDK Runtime Environment (build 1.8.0_232-ea-8u232-b09-0ubuntu1-b09)
OpenJDK 64-Bit Server VM (build 25.232-b09, mixed mode)
Java 11:
openjdk version "11.0.5-ea" 2019-10-15
OpenJDK Runtime Environment (build 11.0.5-ea+10-post-Ubuntu-0ubuntu1)
OpenJDK 64-Bit Server VM (build 11.0.5-ea+10-post-Ubuntu-0ubuntu1, mixed mode, sharing)
# Run complete. Total time: 00:16:03
Benchmark Mode Samples Score Score error Units
c.z.MyBenchmark.boyerMoore thrpt 200 92.854 0.547 ops/s
c.z.MyBenchmark.java thrpt 200 42.131 0.269 ops/s
# Run complete. Total time: 00:16:04
Benchmark Mode Samples Score Score error Units
c.z.MyBenchmark.boyerMoore thrpt 200 92.897 0.531 ops/s
c.z.MyBenchmark.java thrpt 200 49.282 0.424 ops/s
# Run complete. Total time: 00:16:03
Benchmark Mode Samples Score Score error Units
c.z.MyBenchmark.boyerMoore thrpt 200 118.220 0.526 ops/s
c.z.MyBenchmark.java thrpt 200 77.606 0.919 ops/s
# Run complete. Total time: 00:16:04
Benchmark Mode Samples Score Score error Units
c.z.MyBenchmark.boyerMoore thrpt 200 115.957 0.971 ops/s
c.z.MyBenchmark.java thrpt 200 83.801 0.990 ops/s
Short:
Hello, world! I am a string; perhaps I can ananate how, for ananananananars, and more!
Long:
Hello, nanana world! I anana am a string; perhaps nanas I can ananate how, anana for ananananananars, and nanas more!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment