Skip to content

Commit 137774a

Browse files
committed
Add --timing option to check times for getPlanes()
1 parent dfb9de8 commit 137774a

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

scripts/check_pixels.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def log(message):
1818
print(message)
1919

2020

21-
def check_image(idr_conn, image, max_planes):
21+
def check_image(idr_conn, image, max_planes, check_timing=False):
2222

2323
try:
2424
sizeZ = image.getSizeZ()
@@ -44,8 +44,18 @@ def check_image(idr_conn, image, max_planes):
4444
log("Error: Image not found on IDR: %s" % image.id)
4545
return
4646

47-
planes = image.getPrimaryPixels().getPlanes(zctList)
48-
idr_planes = idr_image.getPrimaryPixels().getPlanes(zctList)
47+
start_local = datetime.now()
48+
planes = list(image.getPrimaryPixels().getPlanes(zctList))
49+
planes_time_local = datetime.now() - start_local
50+
51+
start_idr = datetime.now()
52+
idr_planes = list(idr_image.getPrimaryPixels().getPlanes(zctList))
53+
planes_time_idr = datetime.now() - start_idr
54+
55+
if check_timing:
56+
ratio = planes_time_local.microseconds / planes_time_idr.microseconds
57+
log("Ratio of local/IDR timing for %s planes is %s Image: %s" % (len(zctList), ratio, image.id))
58+
log("Local took %s, IDR took %s" % (planes_time_local, planes_time_idr))
4959

5060
for plane, idr_plane, idx in zip(planes, idr_planes, zctList):
5161
if not np.array_equiv(plane, idr_plane):
@@ -115,6 +125,7 @@ def main(argv):
115125
help='Max number of images per FILESET. Default is to check ALL')
116126
parser.add_argument('--max-planes',
117127
help='Max number of planes to check per image or sizeC to check 1 from each Channel. Default is to check ALL')
128+
parser.add_argument('--timing', action="store_true", help="print timing difference between local and IDR")
118129
args = parser.parse_args(argv)
119130

120131
max_images = args.max_images
@@ -125,6 +136,7 @@ def main(argv):
125136
log("Checking %s" % obj_string)
126137
log('max_planes: %s' % max_planes)
127138
log('max_images: %s' % max_images)
139+
log('check timing: %s' % args.timing)
128140

129141
with cli_login() as cli:
130142
conn = BlitzGateway(client_obj=cli._client)
@@ -149,7 +161,7 @@ def main(argv):
149161
total = len(images)
150162
for count, image in enumerate(images):
151163
log("%s/%s Check Image:%s %s" % (count, total, image.id, image.name))
152-
check_image(idr_conn, image, max_planes)
164+
check_image(idr_conn, image, max_planes, check_timing=args.timing)
153165

154166
log("End: %s" % datetime.now())
155167

0 commit comments

Comments
 (0)