我想在HTML5中测量canvas和svg之间的性能.
到目前为止我已经完成了.我在svg和canvas中创建了多个圆圈.两者都具有500 x 500的元件宽度和高度.
我发现我正在衡量脚本编写时间.如果我在Chrome中使用开发工具,则脚本编写时间几乎等于我测量的时间.现在,我该如何测量渲染时间?将是一个带有单独的canvas和svg circle创建和devtools的代码,用于渲染比较svg和canvas渲染性能的好方法吗?
<html>
<head>
<script type="text/javascript">
var svgNS = "http://www.w3.org/2000/svg";
function createCircle1() {
var t3 = performance.now();
for (var x = 1; x <= 1000; x++) {
for (var y = 1; y <= 100; y++) {
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.beginPath();
ctx.arc(x, y, 5, 0, 2 * Math.PI);
ctx.stroke();
}
}
var t4 = performance.now();
console.log("canvas time " + (t4 - t3) + " milliseconds.")
var t0 = performance.now();
for (var …Run Code Online (Sandbox Code Playgroud) 我有一个OpenstreetMap带leaflet.我正在使用这个 Plugin for leaflet来查询Overpass.
var opl = new L.OverPassLayer({
query: "(area['name'='Roma']; node(area)['amenity'='drinking_water']);out;",
});
Run Code Online (Sandbox Code Playgroud)
但是当插件使用时,我的地图没有显示任何内容.
怎么了?
注意:我的查询基于此工作.
编辑:
该查询正在与插件,但不是在http://overpass-turbo.eu/?!
var opl = new L.OverPassLayer({
query: "(node(BBOX)['amenity'='drinking_water'];);out;",
Run Code Online (Sandbox Code Playgroud)
});
完整示例:
var attr_osm = 'Map data © <a href="http://openstreetmap.org/">OpenStreetMap</a> contributors',
attr_overpass = 'POI via <a href="http://www.overpass-api.de/">Overpass API</a>';
var osm = new L.TileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {opacity: 0.7, attribution: [attr_osm, attr_overpass].join(', ')});
var map = new L.Map('map').addLayer(osm).setView(new L.LatLng(49.592041, 8.648164),2);
//OverPassAPI overlay
var opl = new L.OverPassLayer({
query: "(node(BBOX)['amenity'='drinking_water'];);out;",
}); …Run Code Online (Sandbox Code Playgroud) 我已经开始了一份贤者的工作:
from sagemaker.tensorflow import TensorFlow
mytraining= TensorFlow(entry_point='model.py',
role=role,
train_instance_count=1,
train_instance_type='ml.p2.xlarge',
framework_version='2.0.0',
py_version='py3',
distributions={'parameter_server'{'enabled':False}})
training_data_uri ='s3://path/to/my/data'
mytraining.fit(training_data_uri,run_tensorboard_locally=True)
Run Code Online (Sandbox Code Playgroud)
使用run_tesorboard_locally=True给了我
Tensorboard is not supported with script mode. You can run the following command: tensorboard --logdir None --host localhost --port 6006 This can be run from anywhere with access to the S3 URI used as the logdir.
Run Code Online (Sandbox Code Playgroud)
好像我不能使用它的脚本模式,但我可以访问s3中tensorboard的日志?但是s3中的日志在哪里呢?
def _parse_args():
parser = argparse.ArgumentParser()
# Data, model, and output directories
# model_dir is always passed in from SageMaker. By default this is a …Run Code Online (Sandbox Code Playgroud) amazon-web-services tensorboard amazon-sagemaker tensorflow2.0
如果Kappa-Architecture直接对流进行分析而不是将数据分成两个流,那么数据存储在哪里,就像Kafka这样的消息系统?或者它可以在数据库中重新计算?
与使用流处理引擎重新计算以进行批量分析相比,单独的批处理层是否更快?
stream-processing bigdata batch-processing apache-kafka lambda-architecture
我正在尝试使用 Cognito 对 Java 应用程序进行身份验证。我在 python 中使用了运行良好的保证库。但我现在想在java中做同样的事情。
我用我的 Python 函数对保证库进行身份验证
def SRPauthentication(organizationAdmin,
password,
pool_id,
client_id,
client):
aws = AWSSRP(username=organizationAdmin,
password=password,
pool_id=pool_id,
client_id=client_id,
client=client)
tokens = aws.authenticate_user()
authorization_token= tokens['AuthenticationResult']['IdToken']
return authorization_token
Run Code Online (Sandbox Code Playgroud)
有了这个,我可以轻松访问一些安全的 API。现在我想用 Java 做同样的事情,但我有问题。
到目前为止,这是我的解决方案是这种方法:
public static void GetCreds()
{
AWSCognitoIdentityProvider identityProvider = AWSCognitoIdentityProviderClientBuilder.defaultClient();
AdminInitiateAuthRequest adminInitiateAuthRequest = new AdminInitiateAuthRequest().
withAuthFlow(AuthFlowType.USER_SRP_AUTH).
withClientId("234234234234").withUserPoolId("eu-central-1_sdfsdfdsf")
.addAuthParametersEntry("USERNAME", "UserK").
addAuthParametersEntry("PASSWORD","#######);
adminInitiateAuthRequest.getAuthFlow();
AdminInitiateAuthResult adminInitiateAuth = identityProvider.adminInitiateAuth(adminInitiateAuthRequest);
System.out.println(adminInitiateAuth.getAuthenticationResult().getIdToken());
}
Run Code Online (Sandbox Code Playgroud)
当我运行它时,我得到一个异常:
Exception in thread "main" `com.amazonaws.services.cognitoidp.model.AWSCognitoIdentityProviderException: User: arn:aws:iam::XXXXXXXXXXXXXXXXX:user/khan is not authorized to perform: cognito-idp:AdminInitiateAuth on resource: arn:aws:cognito-idp:eu-central-1:XXXXXXXX:userpool/eu-central-1_XXXXXXX …Run Code Online (Sandbox Code Playgroud) java amazon-web-services srp-protocol amazon-cognito aws-java-sdk
我试图在dynamodb中查询主键是时间戳的数据集。首先,我想获取特定传感器ID的所有数据。我尝试了扫描(scan.json):
{
"sensorId": {
"AttributeValueList": [{
"S": "1234"
}],
"ComparisonOperator": "EQ"
}
}
Run Code Online (Sandbox Code Playgroud)
此Json通过CLI命令使用:
aws dynamodb scan --table-name sensorData --scan-filter file://scan.json
Run Code Online (Sandbox Code Playgroud)
那成功了,并为我提供了指定sensorid的所有数据。
现在,如果我只希望将时间戳记和sensorId作为结果,那么我将了解有关projection-expression的信息,并尝试执行查询(query.json):
{
":Id":{"S":"1234"}
}
Run Code Online (Sandbox Code Playgroud)
aws cli命令
aws dynamodb query --table-name sensorData --key-condition-expression "sensorId= :Id" --expression-attribute-values file://query2.json --projection-expression "timestamp"
Run Code Online (Sandbox Code Playgroud)
给我 :
调用查询操作时发生错误(ValidationException):无效的ProjectionExpression:属性名称是保留的关键字;保留关键字:时间戳记
但是出于测试目的,将“ timestamp”替换为“ sensorId”给了我:
调用Query操作时发生错误(ValidationException):查询条件缺少关键架构元素:时间戳记
而且我了解到sensorId对于键表达式无效。。KeyConditionExpression仅接受键属性,哈希键和范围键。但是如何得到结果呢?
我只需要sensorId的时间戳。我的主键错了吗?最好使用sensorId作为主键以及将时间戳作为范围键?
我有一个Jupiter-notebook在 AWS 上运行的 python 应用程序。我将 a 加载C-library到我的 python 代码中,它需要一个文件的路径。我想从 S3 存储桶访问此文件。
我尝试使用 s3fs:
s3 = s3fs.S3FileSystem(anon=False)
Run Code Online (Sandbox Code Playgroud)
usings3.ls('..')列出了我所有的存储桶文件...到目前为止还可以。但是,我使用的库实际上应该在我无法访问的地方使用 s3 变量。我只能将路径传递给c库。
有没有办法以某种方式挂载 s3 存储桶,在那里我不必调用
s3.open(),并且可以调用open(/path/to/s3)隐藏的某个地方,s3 存储桶实际上是作为本地文件系统挂载的?
我认为它应该在不使用 s3 的情况下工作。因为我无法更改我在内部使用的库来使用 s3 变量...
with s3.open("path/to/s3/file",'w') as f:
df.to_csv(f)
with open("path/to/s3/file",'w') as f:
df.to_csv(f)
Run Code Online (Sandbox Code Playgroud)
还是我完全错了?
iam 使用的 c 库在 python 中作为 DLL 加载,我调用了一个函数:
lib.OpenFile(path/to/s3/file)
Run Code Online (Sandbox Code Playgroud)
我必须将路径传递s3到库 OpenFile 函数中。
我创建了一个数据框并使用 pyarrow 将 df 转换为 parquet 文件(此处也提到):
def convert_df_to_parquet(self,df):
table = pa.Table.from_pandas(df)
buf = pa.BufferOutputStream()
pq.write_table(table, buf)
return buf
Run Code Online (Sandbox Code Playgroud)
现在我想将其上传到 s3 存储桶,并尝试了不同的输入参数,因为upload_file()我尝试过的所有操作都不起作用:
s3_client.upload_file(parquet_file, bucket_name, destination_key)#1st
s3_client.put_object(Bucket=bucket_name, Key=destination_key, Body=parquet_file)#2nd
s3_client.put_object(Bucket=bucket_name, Key=destination_key, Body=parquet_file.getvalue())#3rd
s3_client.put_object(Bucket=bucket_name, Key=destination_key, Body=parquet_file.read1())#4th
Run Code Online (Sandbox Code Playgroud)
错误:
s3_client.put_object(Bucket=bucket_name, Key=destination_key, Body=parquet_file.read1())
File "pyarrow/io.pxi", line 376, in pyarrow.lib.NativeFile.read1
File "pyarrow/io.pxi", line 310, in pyarrow.lib.NativeFile.read
File "pyarrow/io.pxi", line 320, in pyarrow.lib.NativeFile.read
File "pyarrow/io.pxi", line 155, in pyarrow.lib.NativeFile.get_input_stream
File "pyarrow/io.pxi", line 170, in pyarrow.lib.NativeFile._assert_readable
OSError: only valid on readonly files
Run Code Online (Sandbox Code Playgroud) 我想在mysql中选择一个日期范围.
$dateFrom='2016-01-01';
$dateTo='2016-01-02';
Run Code Online (Sandbox Code Playgroud)
不工作
query ="SELECT ".$name.",timestamp FROM people where age=".$age." AND timestamp>=".$dateFrom." AND timestamp<.$dateTo";
Run Code Online (Sandbox Code Playgroud)
工作
query ="SELECT ".$name.",timestamp FROM people where age=".$age." AND timestamp>='2016-01-01' AND timestamp<'2016-01-02';
Run Code Online (Sandbox Code Playgroud) amazon-s3 ×2
javascript ×2
python ×2
apache-kafka ×1
aws-cli ×1
aws-java-sdk ×1
bigdata ×1
boto3 ×1
canvas ×1
css ×1
geojson ×1
html5 ×1
java ×1
leaflet ×1
mysql ×1
overpass-api ×1
php ×1
pyarrow ×1
python-s3fs ×1
srp-protocol ×1
svg ×1
tensorboard ×1