-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
753014b
commit ba9a936
Showing
8 changed files
with
131 additions
and
15 deletions.
There are no files selected for viewing
This file contains 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
31 changes: 31 additions & 0 deletions
31
...src/main/kotlin/org/vitrivr/engine/query/operators/transform/benchmark/BenchmarkLogger.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package org.vitrivr.engine.query.operators.transform.benchmark | ||
|
||
import io.github.oshai.kotlinlogging.KLogger | ||
import io.github.oshai.kotlinlogging.KotlinLogging | ||
import org.apache.logging.log4j.message.Message | ||
import org.vitrivr.engine.query.aggregate.logger | ||
import java.nio.file.Path | ||
import java.util.concurrent.BlockingQueue | ||
import java.util.concurrent.LinkedBlockingQueue | ||
|
||
|
||
class BenchmarkLogger(logfile: Path) : Runnable { | ||
private val logger: KLogger = KotlinLogging.logger {} | ||
|
||
private val queue: BlockingQueue<BenchmarkMessage> = LinkedBlockingQueue() | ||
|
||
infix fun log(message: BenchmarkMessage) { | ||
queue.add(message) | ||
} | ||
|
||
override fun run() { | ||
while (true) { | ||
try { | ||
val log = queue.take() | ||
logger.info { log } | ||
} catch (e: InterruptedException) { | ||
e.printStackTrace() | ||
} | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...rc/main/kotlin/org/vitrivr/engine/query/operators/transform/benchmark/BenchmarkMessage.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package org.vitrivr.engine.query.operators.transform.benchmark | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class BenchmarkMessage ( | ||
val name: String, | ||
val source: String, | ||
val timestamp: String | ||
) |
52 changes: 52 additions & 0 deletions
52
...y/src/main/kotlin/org/vitrivr/engine/query/operators/transform/benchmark/TimeBenchmark.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package org.vitrivr.engine.query.operators.transform.benchmark | ||
|
||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.emitAll | ||
import kotlinx.coroutines.flow.flow | ||
import kotlinx.coroutines.flow.toList | ||
import org.vitrivr.engine.core.database.descriptor.DescriptorReader | ||
import org.vitrivr.engine.core.model.metamodel.Schema | ||
import org.vitrivr.engine.core.model.retrievable.Retrievable | ||
import org.vitrivr.engine.core.model.retrievable.Retrieved | ||
import org.vitrivr.engine.core.model.retrievable.attributes.PropertyAttribute | ||
import org.vitrivr.engine.core.model.types.Value | ||
import org.vitrivr.engine.core.operators.Operator | ||
import org.vitrivr.engine.core.operators.general.Transformer | ||
import java.nio.file.Path | ||
import javax.management.Descriptor | ||
|
||
/** | ||
* Appends [Descriptor] to a [Retrieved] based on the values of a [Schema.Field], if available. | ||
* | ||
* @version 1.1.2 | ||
* @author Luca Rossetto | ||
* @author Ralph Gasser | ||
*/ | ||
class TimeBenchmark( | ||
override val input: Operator<out Retrievable>, | ||
val path: Path, | ||
val pretty: String, | ||
override val name: String | ||
) : Transformer { | ||
|
||
companion object { | ||
@Volatile | ||
private var bl: BenchmarkLogger? = null | ||
} | ||
|
||
init { | ||
if (bl == null) { | ||
bl = BenchmarkLogger(path) | ||
Thread(bl).start() | ||
} | ||
} | ||
|
||
|
||
override fun toFlow(scope: CoroutineScope): Flow<Retrievable> = flow { | ||
bl!! log BenchmarkMessage(name, pretty, System.currentTimeMillis().toString()) | ||
emitAll(input.toFlow(scope)) | ||
} | ||
} | ||
|
||
|
17 changes: 17 additions & 0 deletions
17
...ain/kotlin/org/vitrivr/engine/query/operators/transform/benchmark/TimeBenchmarkFactory.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.vitrivr.engine.query.operators.transform.benchmark | ||
|
||
import org.vitrivr.engine.core.context.Context | ||
import org.vitrivr.engine.core.context.QueryContext | ||
import org.vitrivr.engine.core.model.retrievable.Retrievable | ||
import org.vitrivr.engine.core.operators.Operator | ||
import org.vitrivr.engine.core.operators.general.TransformerFactory | ||
import kotlin.io.path.Path | ||
|
||
class TimeBenchmarkFactory() : TransformerFactory { | ||
override fun newTransformer(name: String, input: Operator<out Retrievable>, context: Context): TimeBenchmark { | ||
require(context is QueryContext) | ||
val logfilePath = Path(context[name, "logfile"]?.toString() ?: "benchmark.log") | ||
val prettyName = context[name, "pretty"]?.toString() ?: name | ||
return TimeBenchmark(input, logfilePath, prettyName, name) | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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