Skip to content

Commit

Permalink
Add elapsed time info for responses
Browse files Browse the repository at this point in the history
- Total time
- Custom named events with elapsed time (map)
  • Loading branch information
jorgenherje committed Mar 19, 2024
1 parent 88ef3a6 commit 2872e98
Show file tree
Hide file tree
Showing 8 changed files with 169 additions and 31 deletions.
10 changes: 9 additions & 1 deletion GrpcInterface/GrpcProtos/GridGeometryExtraction.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ service GridGeometryExtraction
rpc CutAlongPolyline(CutAlongPolylineRequest) returns (CutAlongPolylineResponse);
}

message TimeElapsedInfo
{
fixed32 totalTimeElapsedMs = 1; // Total time elapsed for the entire request
map<string, fixed32> namedEventsAndTimeElapsedMs = 2; // Time elapsed for each custom named event
}

message IJKIndexFilter
{
int32 iMin = 1;
Expand Down Expand Up @@ -49,6 +55,7 @@ message GetGridSurfaceResponse
repeated fixed32 sourceCellIndicesArr = 3; // The originating cell index per quad, longnumQuads long
Vec3i gridDimensions = 5;
Vec3d originUtm = 6;
TimeElapsedInfo timeElapsedInfo = 7;
}

message CutAlongPolylineRequest
Expand Down Expand Up @@ -80,6 +87,7 @@ message CutAlongPolylineResponse
{
repeated FenceMeshSection fenceMeshSections = 1;
PolylineTestResponse polylineTestResponse = 2;
Vec3i gridDimensions = 3;
TimeElapsedInfo timeElapsedInfo = 3;
Vec3i gridDimensions = 4;
}

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

grid_file_name = "MOCKED_TEST_GRID"
grid_file_name = (
"D:\\Git\\resinsight-tutorials\\model-data\\norne\\NORNE_ATW2013_RFTPLT_V2.EGRID"
"D:/Git/resinsight-tutorials/model-data/norne/NORNE_ATW2013_RFTPLT_V2.EGRID"
)

# Test polylines
Expand Down Expand Up @@ -53,6 +53,11 @@
grid_geometry_extraction_stub.CutAlongPolyline(cut_along_polyline_request)
)

total_time_elapsed = cut_along_polyline_response.timeElapsedInfo.totalTimeElapsedMs
named_events_and_time_elapsed = (
cut_along_polyline_response.timeElapsedInfo.namedEventsAndTimeElapsedMs
)

fence_mesh_sections = cut_along_polyline_response.fenceMeshSections
print(f"Number of fence mesh sections: {len(fence_mesh_sections)}")

Expand Down Expand Up @@ -201,5 +206,9 @@
# f"Grid dimensions [I, J, K]: [{grid_dimensions.dimensions.i}, {grid_dimensions.dimensions.j}, {grid_dimensions.dimensions.k}]"
# )
print(fig.data)
print(f"Total time elapsed: {total_time_elapsed} ms")
# print(f"Time elapsed per event [ms]: {named_events_and_time_elapsed}")
for message, time_elapsed in named_events_and_time_elapsed.items():
print(f"{message}: {time_elapsed}")

fig.show()
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

# grid_file_name = "MOCKED_TEST_GRID"
grid_file_name = (
"D:\\Git\\resinsight-tutorials\\model-data\\norne\\NORNE_ATW2013_RFTPLT_V2.EGRID"
"D:/Git/resinsight-tutorials/model-data/norne/NORNE_ATW2013_RFTPLT_V2.EGRID"
)

# Test polylines
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

grid_file_name = "MOCKED_TEST_GRID"
grid_file_name = (
"D:\\Git\\resinsight-tutorials\\model-data\\norne\\NORNE_ATW2013_RFTPLT_V2.EGRID"
"D:/Git/resinsight-tutorials/model-data/norne/NORNE_ATW2013_RFTPLT_V2.EGRID"
)

# Test polylines
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,22 @@
from rips.generated.GridGeometryExtraction_pb2_grpc import *
from rips.generated.GridGeometryExtraction_pb2 import *

# from ..instance import *
# from ..generated.GridGeometryExtraction_pb2_grpc import *
# from ..generated.GridGeometryExtraction_pb2 import *

rips_instance = Instance.find()
grid_geometry_extraction_stub = GridGeometryExtractionStub(rips_instance.channel)

# grid_file_name = "MOCKED_TEST_GRID"
grid_file_name = (
"D:\\Git\\resinsight-tutorials\\model-data\\norne\\NORNE_ATW2013_RFTPLT_V2.EGRID"
"D:/Git/resinsight-tutorials/model-data/norne/NORNE_ATW2013_RFTPLT_V2.EGRID"
)
# grid_file_name = "MOCKED_TEST_GRID"

# ijk_index_filter = GridGeometryExtraction__pb2.IJKIndexFilter(
# iMin=0, iMax=1, jMin=1, jMax=3, kMin=3, kMax=3
# )
ijk_index_filter = None
ijk_index_filter = GridGeometryExtraction__pb2.IJKIndexFilter(
iMin=-1, iMax=-1, jMin=-1, jMax=-1, kMin=-1, kMax=-1
)
# ijk_index_filter = None

get_grid_surface_request = GridGeometryExtraction__pb2.GetGridSurfaceRequest(
gridFilename=grid_file_name,
Expand All @@ -29,6 +33,11 @@
grid_geometry_extraction_stub.GetGridSurface(get_grid_surface_request)
)

total_time_elapsed = get_grid_surface_response.timeElapsedInfo.totalTimeElapsedMs
named_events_and_time_elapsed = (
get_grid_surface_response.timeElapsedInfo.namedEventsAndTimeElapsedMs
)

vertex_array = get_grid_surface_response.vertexArray
quad_indices_array = get_grid_surface_response.quadIndicesArr
origin_utm = get_grid_surface_response.originUtm
Expand All @@ -44,9 +53,9 @@
y_array = []
z_array = []
for i in range(0, len(vertex_array), num_vertex_coords):
x_array.append(vertex_array[i + 0] + origin_utm.x)
y_array.append(vertex_array[i + 1] + origin_utm.y)
z_array.append(vertex_array[i + 2] + origin_utm.z)
x_array.append(vertex_array[i + 0])
y_array.append(vertex_array[i + 1])
z_array.append(vertex_array[i + 2])

# Create triangular mesh
i_array = []
Expand Down Expand Up @@ -75,6 +84,7 @@
]
)


print(f"Number of quads: {num_quads}")
print(f"Source cell indices array length: {len(source_cell_indices_arr)}")
print(
Expand All @@ -85,4 +95,9 @@
)
print(fig.data)

print(f"Total time elapsed: {total_time_elapsed} ms")
# print(f"Time elapsed per event [ms]: {named_events_and_time_elapsed}")
for message, time_elapsed in named_events_and_time_elapsed.items():
print(f"{message}: {time_elapsed}")

fig.show()
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

# grid_file_name = "MOCKED_TEST_GRID"
grid_file_name = (
"D:\\Git\\resinsight-tutorials\\model-data\\norne\\NORNE_ATW2013_RFTPLT_V2.EGRID"
"D:/Git/resinsight-tutorials/model-data/norne/NORNE_ATW2013_RFTPLT_V2.EGRID"
)

# ijk_index_filter = GridGeometryExtraction__pb2.IJKIndexFilter(
Expand Down
Loading

0 comments on commit 2872e98

Please sign in to comment.