python代码
import ast
import copy
import datetime
import json
import os
import random
import subprocess
import sys
import open3d as o3d;
import numpy as np
import pip;
import mmap
from multiprocessing import shared_memory
import requests
if __name__ == "__main__":
print("version")
print(sys.path)
print(o3d.__version__)
print(sys.version)
print(sys.executable)
print(pip.__version__)
print(pip.__file__)
print(sys.getwindowsversion())
try:
try:
print (f'开始测试 {datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')}')
# 定义curl命令和参数
curl_command = ['curl', '-X', 'GET', 'http://127.0.0.1:8200/Python/GetPlyDataV2']
# 执行curl命令
result = subprocess.run(curl_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
print(result.args)
print ('开始测试 1')
#print(result.stderr)
print ('开始测试 2')
#print(result.stdout)
print (f'开始测试 3 {datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')}')
data = json.loads(result.stdout.decode('utf-8'))
print (f'开始测试 4 {datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')}')
print (f'开始测试 -----{len(data)}')
#print(data)
except Exception as e:
print(f"请求异常: {e}")
except Exception as e:
print(e)
print('ok')
print("version end")
C#代码
[HttpGet(Name = "GetPlyDataV2")]
public ConcurrentQueue<ConcurrentQueue<double>> GetPlyDataV2()
{
Random random = new Random();
int DataLength = 1001000;
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
// 或者预填充
ConcurrentQueue<ConcurrentQueue<double>> Mylist2DFilled = new ConcurrentQueue<ConcurrentQueue<double>>();
//Log.Logger.Debug($"开始添加数据 ");
for (int row = 0; row < DataLength; row++)
{
ConcurrentQueue<double> rowList = new ConcurrentQueue<double>();
for (int col = 0; col < 3; col++)
{
rowList.Enqueue(random.NextDouble());
}
list2DFilled.Enqueue(rowList);
}
Log.Logger.Debug($"结束添加数据 ");
stopwatch.Stop();
Log.Logger.Debug($"ElapsedMilliseconds = [{stopwatch.ElapsedMilliseconds}] ");
return Mylist2DFilled;
}
python测试结果

想通过http传递大约8位数长度的二维数组给python,测试7位数以上耗时1秒多,但是8位数耗时就大大增大。目前超过1秒,就不满足我的要求。