我正在编写一个Web应用程序,它使用websockets进行客户端和服务器之间的双向通信.我主要担心的是用户感知的延迟,所以,我正在测量和分析我能做什么.特别是,我正在onmessage()事件中捕获当前时间.这很有用,但我也想知道事件何时被推入浏览器的事件循环 - 这发生在触发onmessage事件之前.
在Chrome开发者工具中,我在"网络 - >框架"标签中看到了时间,我认为这是事件进入事件循环的时间.但我需要在Javascript中以编程方式捕获它.知道怎么做吗?
我做了一些"console.log",并在一些情况下看到了开发人员工具中显示的时间与我在onmessage事件中捕获的时间之间大约10毫秒的差异.我希望我的测量结果能够显示差异是否始终小到10毫秒,或者由于渲染或页面中发生的其他事情,有时差异是否更高.
我已将来自aws-dynamodb-examples的DynamoDB流适配器演示的代码合并到我的Maven项目中,并且我遇到了运行时错误:
Exception in thread "Thread-2" java.lang.NoClassDefFoundError: com/amazonaws/util/json/JSONObject
at com.amazonaws.services.kinesis.leases.impl.Lease.toString(Lease.java:229)
Run Code Online (Sandbox Code Playgroud)
知道为什么会这样,以及我可以做些什么来修复它?
我的pom文件是这样的:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.aligntech</groupId>
<artifactId>dynamodbstream</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>dynamodbstream</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<version>LATEST</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>dynamodb-streams-kinesis-adapter</artifactId>
<version>LATEST</version>
</dependency>
</dependencies>
</project>
Run Code Online (Sandbox Code Playgroud) java amazon-web-services amazon-dynamodb amazon-kinesis amazon-dynamodb-streams
这是一个关于如何从forClojure中的嵌套循环中正确收集结果的问题.假设你想创建所有向量序列[i j],其中0<=j<i<4
以下代码
(for [i (range 1 4)]
(for [j (range i)]
[i j]
)
)
Run Code Online (Sandbox Code Playgroud)
产生
(([1 0]) ([2 0] [2 1]) ([3 0] [3 1] [3 2]))
Run Code Online (Sandbox Code Playgroud)
但我真正想要的是
([1 0] [2 0] [2 1] [3 0] [3 1] [3 2])
Run Code Online (Sandbox Code Playgroud)
这样做的正确方法是什么?
请注意,我对这个特定的序列不感兴趣.我的目的是学习如何从嵌套for循环中收集结果,这是我需要解决更复杂的问题.