test.py
1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# coding=utf-8
#author: 4N
#createtime: 2021/9/27
#email: nheweijun@sina.com
# from .ttypes import RasterData
from thrift.transport import TSocket
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol
from app.modules.service.image.tutorial import Calculator
from app.modules.service.image.ImageDataService import ImageDataService
import time
def test1():
host = "172.26.60.100"
port = 8850
transport: TSocket = TSocket.TSocket(host, port)
transport = TTransport.TBufferedTransport(transport)
protocol = TBinaryProtocol.TBinaryProtocol(transport)
client = Calculator.Client(protocol)
transport.open()
import sys
test = client.getData("江南_01.tif",[1340.27, -1911.31, 4351.79, 5410.6],[1340.27, -1911.31, 4351.79, 5410.6],[3,2,1],768,768)
print(sys.getsizeof(test[1]))
# print(test)
def test2():
host = "172.26.60.100"
port = 9090
transport: TSocket = TSocket.TSocket(host, port)
transport = TTransport.TBufferedTransport(transport)
protocol = TBinaryProtocol.TBinaryProtocol(transport)
client = ImageDataService.Client(protocol)
transport.open()
test = client.getData("/usr/src/data/江南_01.tif", [1340.27, -1911.31, 4351.79, 5410.6], [1340.27, -1911.31, 4351.79, 5410.6],
[1,2,3], 768, 768)
import gzip,numpy
data = gzip.decompress(test)
# data = numpy.frombuffer(data, dtype='int64')
# data = data.reshape((768, 768, 3))
import sys
print(sys.getsizeof(data))
# print(test)
if __name__ == '__main__':
t1 = time.time()
# test1()
print(time.time()-t1)
t2 = time.time()
test2()
print(time.time()-t2)