Skip to content

Instantly share code, notes, and snippets.

Avatar

David Ohana davidohana

View GitHub Profile
View peasyshell_sample_app_docker.py
#!/usr/bin/env python2
from peasyshell import *
# initialize logging to stdout in colors by severity level
init_logging()
cfg = {
"container_name": "ELASTIC",
"image_name": "elasticsearch:6.8.13"
View profiling-sample-kotlin-output.txt
app started
total : took 9.91 s (100.00%), 84,514 samples, 117.27 ( 117.27) ms / 1000 samples, 8,527.43 ( 8,527.43) hz
hashing : took 9.84 s ( 99.30%), 84,514 samples, 116.45 ( 116.45) ms / 1000 samples, 8,587.60 ( 8,587.60) hz
sha1 : took 4.00 s ( 40.37%), 84,514 samples, 47.34 ( 47.34) ms / 1000 samples, 21,122.58 ( 21,122.58) hz
sha256 : took 3.10 s ( 31.25%), 84,514 samples, 36.64 ( 36.64) ms / 1000 samples, 27,291.05 ( 27,291.05) hz
md5 : took 2.68 s ( 27.01%), 84,514 samples, 31.68 ( 31.68) ms / 1000 samples, 31,567.98 ( 31,567.98) hz
init : took 0.02 s ( 0.24%), 1 samples, 23,563.30 (23,563.30) ms / 1000 samples, 42.44 ( 42.44) hz
random : took 0.01 s ( 0.14%), 84,514 samples, 0.17 ( 0.17) ms / 1000 samples, 5,931,448.03 ( 5,931,448.03) hz
sqrt : took 0.01 s ( 0.
View profiling-sample-python-output.txt
app started
total : took 9.68 s (100.00%), 141,637 samples, 68.32 ( 68.32) ms / 1000 samples, 14,635.93 ( 14,635.93) hz
hashing : took 8.71 s ( 89.97%), 141,637 samples, 61.47 ( 61.47) ms / 1000 samples, 16,267.09 ( 16,267.09) hz
sha256 : took 3.68 s ( 37.99%), 141,637 samples, 25.96 ( 25.96) ms / 1000 samples, 38,521.19 ( 38,521.19) hz
md5 : took 2.41 s ( 24.93%), 141,637 samples, 17.03 ( 17.03) ms / 1000 samples, 58,709.23 ( 58,709.23) hz
sha1 : took 1.76 s ( 18.21%), 141,637 samples, 12.44 ( 12.44) ms / 1000 samples, 80,370.26 ( 80,370.26) hz
random : took 0.09 s ( 0.93%), 141,637 samples, 0.63 ( 0.63) ms / 1000 samples, 1,577,645.27 ( 1,577,645.27) hz
sqrt : took 0.08 s ( 0.84%), 141,637 samples, 0.58 ( 0.58) ms / 1000 samples, 1,735,753.67 ( 1,735,753.67) hz
init : took 0.00 s ( 0.00%),
View profiler-sample-python.py
import hashlib
import math
import os
import random
from simple_profiler import SimpleProfiler
print("app started")
profiler = SimpleProfiler(reset_after_sample_count=200000)
View profiler-sample-kotlin.kt
import davidoh.profiling.*
import java.security.MessageDigest
import kotlin.math.sqrt
fun main() {
val profiler: Profiler = SimpleProfiler(resetAfterSampleCount = 200000)
println("app started")
profiler.startSection("init")
View profiler-output-log-parser.txt
total : took 25.59 s (100.00%), 195,015 samples, 131.24 ( 116.68) ms / 1000 samples, 7,619.73 ( 8,570.71) hz
parser : took 17.56 s ( 68.62%), 195,015 samples, 90.05 ( 78.85) ms / 1000 samples, 11,104.39 ( 12,682.72) hz
publish : took 6.02 s ( 23.51%), 175,882 samples, 34.21 ( 32.19) ms / 1000 samples, 29,231.77 ( 31,069.33) hz
split : took 4.95 s ( 19.35%), 175,882 samples, 28.16 ( 25.18) ms / 1000 samples, 35,513.22 ( 39,721.53) hz
drain : took 4.73 s ( 18.50%), 7,484 samples, 632.60 ( 632.60) ms / 1000 samples, 1,580.79 ( 1,580.79) hz
mask : took 0.90 s ( 3.51%), 7,484 samples, 120.15 ( 120.15) ms / 1000 samples, 8,323.22 ( 8,323.22) hz
View kk-init.kt
val settings = KofikoSettings()
.addCli(args) { this.overrideToken = "-o" }
.addEnv()
.addSystemProperties()
.addFiles(
"sample_config.json", "sample_config.ini",
"sample_config.env", "sample_config.properties"
)
// optional setting to print config options with non-default value
View kk-classes.kt
class DatabaseConfig {
var user = "default_user"
@Secret
var password = "changeme"
var endpoints = listOf("http://localhost:1234")
var unsafeSSL = false
var dbSizeLimits = mapOf("alerts" to 50, "logs" to 200)
}
View kofiko-ini-example.ini
[LOG]
file_out_folder = ../log-staging
[ELASTIC]
env_name = staging
[MIRROR]
batch_hours = 1
View kofiko_staging_cust.py
@config_custom
def staging():
LogConfig.file_out_folder = "../log-staging"
ElasticConfig.env_name = "staging"
MirrorConfig.batch_hours = 1