Skip to content

Instantly share code, notes, and snippets.

@danie7k
danie7k / measure.swift
Created October 18, 2019 09:27
Quick Performance Timing
@discardableResult
func measure<A>(name: String = "", _ block: () -> A) -> A {
let startTime = CACurrentMediaTime()
let result = block()
let timeElapsed = CACurrentMediaTime() - startTime
print("Time: \(name) - \(timeElapsed)")
return result
}
@danie7k
danie7k / executiontime.swift
Created October 18, 2019 09:28
CFAbsoluteTime measuring
let start = CFAbsoluteTimeGetCurrent()
// run your work
let diff = CFAbsoluteTimeGetCurrent() - start
print("Took \(diff) seconds")
@danie7k
danie7k / QuotesInJenkinsfiles.groovy
Created April 17, 2025 20:20 — forked from agarthetiger/QuotesInJenkinsfiles.groovy
Quoting strings and variable interpolation in Jenkinsfiles, passing values to shell tasks.
node{
timestamps{
stage('Samples'){
// Single quotes with no interpolation, at least not in Jenkins.
// The dollar variable will be evaluated before being run by the
// shell command, so variables which Jenkins makes available as
// environment variables can still be accessed from within a
// single-quoted string, passed to the sh task.
sh 'echo $PATH'