Update throughput of dGraph using Python Client

Can you try this?

I get consistently ~115 updates/second. I’m running a simple local cluster on my Mac M1 Mini. Perhaps a lot of the lag in your version is all the python string parsing per update?

import datetime
from python_graphql_client import GraphqlClient

# Instantiate the client with an endpoint.
client = GraphqlClient(endpoint="http://localhost:8080/graphql")

query = """
mutation($id: String!, $value: Float!) {
  updateSensor(input: {filter: {name: {eq: $id}}, set: {value: $value}}) {
    sensor {
      id
    }
  }
}
"""

name = "temperatureSensor"

start = datetime.datetime.now()
for i in range(1, 101):
    data = client.execute(query=query, variables={"id": name, "value": i*i})
end = datetime.datetime.now()

elapsed = end - start

print(i, "updates in", elapsed.microseconds / 1000, "milliseconds")
print("updates per second", i / (elapsed.microseconds / 1000000))