Coder Social home page Coder Social logo

Add query time to analytics results about tap HOT 8 CLOSED

heta-io avatar heta-io commented on July 29, 2024
Add query time to analytics results

from tap.

Comments (8)

andrewresearch avatar andrewresearch commented on July 29, 2024 1

You don't access the Result object directly as it is a trait. My suggestion is to implemented it as a function that accepts another function as an argument and returns the appropriate result including the timing.
For example if the original function was analyseString(myString:String):StringResult then instead of calling this, we would do something like...

val origFunction = analyseString(myString:String):StringResult

def timedQuery(text:String, analysisFunction:(String) => StringResult):Result = {
  val startTime = System.currentTimeMillis
  val result = analysisFunction(text)
  val queryTime = System.currentTimeMillis - startTime
 // Copy the result object and add in the queryTimeValue here
 // Return the new result
}

// Where the original function was called, we wrap it in the timeQuery function like this...

val newResult = timedQuery(text, origFunction)

from tap.

quanie avatar quanie commented on July 29, 2024

Is query time the starting time or the processing time?

from tap.

andrewresearch avatar andrewresearch commented on July 29, 2024

The processing time. Should be able to do this with System.currentTimeMillis()

from tap.

quanie avatar quanie commented on July 29, 2024

It should be (end time - start time), shouldn't it? If so, the start time has to be inputted along with the query?

from tap.

andrewresearch avatar andrewresearch commented on July 29, 2024

Yes, record the start time before the analysis, get the end time after the analysis, and add it to the Result object before it is returned by the GraphQL Controller.

from tap.

quanie avatar quanie commented on July 29, 2024

I have a problem with accessing fields of the Result object.

from tap.

quanie avatar quanie commented on July 29, 2024

I tried to write a function similar to timedQuery but with different types such as StringResult, SentencesResult, .... However, I was not successful. So this version has some duplicated codes for different case classes.

from tap.

andrewresearch avatar andrewresearch commented on July 29, 2024

See comment in PR.

from tap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.