Quick AIDA port

This commit is contained in:
Alexander Nozik 2018-10-26 20:14:07 +03:00
parent f506e76b69
commit ae34346437
7 changed files with 53 additions and 79 deletions

2
.gitignore vendored
View File

@ -8,4 +8,4 @@
# Cache of project # Cache of project
.gradletasknamecache .gradletasknamecache
gradle.properties artifactory.gradle

View File

@ -13,6 +13,7 @@ buildscript {
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4+" classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4+"
} }
} }
allprojects { allprojects {
apply plugin: 'maven-publish' apply plugin: 'maven-publish'
apply plugin: "com.jfrog.artifactory" apply plugin: "com.jfrog.artifactory"
@ -21,29 +22,6 @@ allprojects {
version = '0.0.1-SNAPSHOT' version = '0.0.1-SNAPSHOT'
} }
if(file('artifactory.gradle').exists()){
artifactory { apply from: 'artifactory.gradle'
contextUrl = "${artifactory_contextUrl}" //The base Artifactory URL if not overridden by the publisher/resolver
publish {
repository {
repoKey = 'gradle-dev-local'
username = "${artifactory_user}"
password = "${artifactory_password}"
}
defaults {
publications('jvm', 'js', 'kotlinMultiplatform', 'metadata')
publishBuildInfo = false
publishArtifacts = true
publishPom = true
publishIvy = false
}
}
resolve {
repository {
repoKey = 'gradle-dev'
username = "${artifactory_user}"
password = "${artifactory_password}"
}
}
} }

View File

@ -0,0 +1,15 @@
plugins {
kotlin("jvm")
}
repositories {
mavenCentral()
maven ("http://dl.bintray.com/kotlin/kotlin-eap")
maven("http://java.freehep.org/maven2/")
}
dependencies {
implementation(kotlin("stdlib"))
api(project(":kmath-core"))
api(group = "org.freehep", name = "freehep-jaida", version = "3.4.13")
}

View File

@ -0,0 +1,9 @@
package scientifik.kmath.aida
import hep.aida.IAnalysisFactory
import hep.aida.IHistogramFactory
import hep.aida.ITreeFactory
val analysisFactory: IAnalysisFactory by lazy { IAnalysisFactory.create() }
val treeFactory: ITreeFactory by lazy { analysisFactory.createTreeFactory() }
val histogramFactory: IHistogramFactory by lazy { analysisFactory.createHistogramFactory(treeFactory.create()) }

View File

@ -0,0 +1,23 @@
package scientifik.kmath.aida
import hep.aida.IHistogram1D
import hep.aida.IHistogram2D
fun Iterable<Double>.histogram(range: ClosedFloatingPointRange<Double>, bins: Int = 100, path: String = ""): IHistogram1D{
val h1d = Histograms.create1D(range,bins,path)
forEach{
h1d.fill(it)
}
return h1d
}
object Histograms {
fun create1D(range: ClosedFloatingPointRange<Double>, bins: Int = 100, path: String = ""): IHistogram1D {
return histogramFactory.createHistogram1D(path, bins, range.start, range.endInclusive)
}
fun create2D(xRange: ClosedFloatingPointRange<Double>, yRange: ClosedFloatingPointRange<Double>, xBins: Int = 100, yBins: Int = 100, path: String = ""): IHistogram2D {
return histogramFactory.createHistogram2D(path, xBins, xRange.start, xRange.endInclusive, yBins, yRange.start, yRange.endInclusive)
}
}

View File

@ -1,52 +0,0 @@
package scietifik.kmath.structures
import java.nio.IntBuffer
@Fork(1)
@Warmup(iterations = 2)
@Measurement(iterations = 5)
@State(Scope.Benchmark)
open class ArrayBenchmark {
lateinit var array: IntArray
lateinit var arrayBuffer: IntBuffer
lateinit var nativeBuffer: IntBuffer
@Setup
fun setup() {
array = IntArray(10000) { it }
arrayBuffer = IntBuffer.wrap(array)
nativeBuffer = IntBuffer.allocate(10000)
for (i in 0 until 10000) {
nativeBuffer.put(i,i)
}
}
@Benchmark
fun benchmarkArrayRead() {
var res = 0
for (i in 1..10000) {
res += array[10000 - i]
}
print(res)
}
@Benchmark
fun benchmarkBufferRead() {
var res = 0
for (i in 1..10000) {
res += arrayBuffer.get(10000 - i)
}
print(res)
}
@Benchmark
fun nativeBufferRead() {
var res = 0
for (i in 1..10000) {
res += nativeBuffer.get(10000 - i)
}
print(res)
}
}

View File

@ -1,7 +1,7 @@
pluginManagement { pluginManagement {
repositories { repositories {
maven { url = 'http://dl.bintray.com/kotlin/kotlin-eap' }
mavenCentral() mavenCentral()
maven { url = 'http://dl.bintray.com/kotlin/kotlin-eap' }
maven { url = 'https://plugins.gradle.org/m2/' } maven { url = 'https://plugins.gradle.org/m2/' }
} }
} }
@ -10,5 +10,6 @@ enableFeaturePreview('GRADLE_METADATA')
rootProject.name = 'kmath' rootProject.name = 'kmath'
include ':kmath-core' include ':kmath-core'
include ':kmath-aida'
include ':kmath-jmh' include ':kmath-jmh'