【问题标题】:Is there a way to see how long was the response from Firebase?有没有办法查看 Firebase 的响应时间?
【发布时间】:2020-05-10 17:28:55
【问题描述】:

我想测试一下 Firebase 在不同设备上的响应时间。 Firebase 在 AVD 上响应(至少对我而言)似乎需要比在真实设备上更长的时间,我想以毫秒为单位比较这些值。例如,我想知道在 Android 虚拟设备上登录 Firebase 身份验证需要多长时间,然后在真正的 android 设备上需要多长时间?如果这很重要,我正在用 Java 编码。

【问题讨论】:

  • 只需在通话之前和通话返回Timestamp timestamp = new Timestamp(System.currentTimeMillis()); 之后获取时间戳。通过计算差异应该可以完成这项工作

标签: java android firebase firebase-authentication


【解决方案1】:

查看多少ms直到响应成功:

long startTime;
long endTime;
long responseTime;


//before you call sign in

startTime = System.currentTimeMillis();

signIn();



private void signIn(){

mAuth.signInWithEmailAndPassword(email, password)
        .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
            @Override
            public void onComplete(@NonNull Task<AuthResult> task) {
                if (task.isSuccessful()) {
                    // Sign in success
                    endTime = System.currentTimeMillis();
                    responseTime = endTime - startTime;
                    Log.d("Time It Takes" , String.valueOf(responseTime));

                }
............
............

}

【讨论】:

    猜你喜欢
    • 2012-07-21
    • 1970-01-01
    • 2020-10-06
    • 1970-01-01
    • 1970-01-01
    • 2019-10-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多