#include <stdlib.h>
void * jmalloc(size_t size) {
return malloc(size);
}
void jfree(void * ptr) {
free(ptr);
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # From https://datatracker.ietf.org/doc/html/draft-msporny-base58-03 | |
| # The description on that page is misleading or just wrong. | |
| # This was derived from converting the Rust code here: | |
| # https://github.com/hachi-bitto/btc-wallet/blob/5dde65a262d3239a23292fc2a4a692994603aeb0/wallet/src/base58.rs | |
| TABLE = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" | |
| FORWARD = {k:v for (k, v) in enumerate(TABLE)} | |
| BACK = {k:v for (v, k) in enumerate(TABLE)} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ordered = ["A", "B", "C", "D", "E", "F"] | |
| def encode_permutation(permutation, ordered): | |
| ordered = ordered.copy() | |
| size = len(ordered) | |
| encoded = 0 | |
| for (i, value) in enumerate(permutation): | |
| fact = factorial(size - i - 1) | |
| idx = ordered.index(value) | |
| ordered.remove(value) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| from PIL import Image | |
| from math import sin, cos, pi | |
| width = 1440 | |
| height = 800 | |
| midw = width / 2 | |
| midh = height / 2 | |
| lesser = min(midw, midh) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import jdk.internal.platform.Metrics; | |
| public class Foo { | |
| static volatile long bah; | |
| public static void main(String [] args) { | |
| Metrics metrics = Metrics.systemMetrics(); | |
| // com.sun.management.internal.OperatingSystemImpl |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <x86intrin.h> | |
| #include <stdio.h> | |
| #include <unistd.h> | |
| #include <stdlib.h> | |
| #include <inttypes.h> | |
| static __inline__ uint64_t rdtsc(void){ | |
| uint32_t hi, lo; | |
| __asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi)); | |
| return ( (uint64_t)lo)|( ((uint64_t)hi)<<32 ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Before | |
| --------------------------------------------------------------------------------------------------------------------------- | |
| Benchmark Time CPU Iterations | |
| --------------------------------------------------------------------------------------------------------------------------- | |
| BM_HpackEncoderInitDestroy 198 ns 198 ns 3535074 | |
| BM_HpackEncoderEncodeDeadline 129 ns 129 ns 5219422 framing_bytes/iter:9 header_bytes/iter:6 | |
| BM_HpackEncoderEncodeHeader<EmptyBatch>/0/16384 31 ns 31 ns 22189800 framing_bytes/iter:9 header_bytes/iter:0 | |
| BM_HpackEncoderEncodeHeader<EmptyBatch>/1/16384 31 ns 31 ns 22162902 framing_bytes/iter:9 header_bytes/iter:0 | |
| BM_HpackEncoderEncodeHeader |
# JMH version: 1.21
# VM version: JDK 13-ea, OpenJDK 64-Bit Server VM, 13-ea+22
# VM invoker: /home/carl/Downloads/jdk-13/bin/java
# VM options: -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:+UseJVMCICompiler -XX:+LogCompilation -XX:LogFile=/tmp/blah.txt -XX:+PrintAssembly -XX:+PrintInterpreter -XX:+PrintNMethods -XX:+PrintNativeNMethods -XX:+PrintSignatureHandlers -XX:+PrintAdapterHandlers -XX:+PrintStubCode -XX:+PrintCompilation -XX:+PrintInlining -XX:+TraceClassLoading -XX:PrintAssemblyOptions=syntax -XX:PrintAssemblyOptions=intel
# Warmup: 10 iterations, 10 s each
# Measurement: 5 iterations, 1 s each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Average time, time/op
C2:
# JMH version: 1.21
# VM version: JDK 11.0.2, Java HotSpot(TM) 64-Bit Server VM, 11.0.2+9-LTS
# VM invoker: /home/carl/bin/jdk-11.0.2/bin/java
# VM options: -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+LogCompilation -XX:LogFile=/tmp/blah.txt -XX:+PrintAssembly -XX:+PrintInterpreter -XX:+PrintNMethods -XX:+PrintNativeNMethods -XX:+PrintSignatureHandlers -XX:+PrintAdapterHandlers -XX:+PrintStubCode -XX:+PrintCompilation -XX:+PrintInlining -XX:+TraceClassLoading -XX:PrintAssemblyOptions=syntax -XX:PrintAssemblyOptions=intel
# Warmup: 10 iterations, 1 s each
# Measurement: 5 iterations, 1 s each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package test; | |
| import java.lang.invoke.MethodHandles; | |
| import java.lang.invoke.VarHandle; | |
| import java.util.concurrent.atomic.AtomicLong; | |
| import org.openjdk.jcstress.annotations.Actor; | |
| import org.openjdk.jcstress.annotations.Expect; | |
| import org.openjdk.jcstress.annotations.JCStressTest; | |
| import org.openjdk.jcstress.annotations.Outcome; |