GCC Code Coverage Report
Directory: ../ Exec Total Coverage
File: /home/iojs/build/workspace/node-test-commit-linux-coverage/nodes/benchmark/out/../src/timers.cc Lines: 31 31 100.0 %
Date: 2019-01-07 12:15:22 Branches: 2 4 50.0 %

Line Branch Exec Source
1
#include "node_internals.h"
2
3
#include <stdint.h>
4
5
namespace node {
6
namespace {
7
8
using v8::Array;
9
using v8::Context;
10
using v8::Function;
11
using v8::FunctionCallbackInfo;
12
using v8::Integer;
13
using v8::Local;
14
using v8::Object;
15
using v8::Value;
16
17
3661
void SetupTimers(const FunctionCallbackInfo<Value>& args) {
18
7322
  CHECK(args[0]->IsFunction());
19
7322
  CHECK(args[1]->IsFunction());
20
3661
  auto env = Environment::GetCurrent(args);
21
22
7322
  env->set_immediate_callback_function(args[0].As<Function>());
23
7322
  env->set_timers_callback_function(args[1].As<Function>());
24
3661
}
25
26
101748
void GetLibuvNow(const FunctionCallbackInfo<Value>& args) {
27
101748
  Environment* env = Environment::GetCurrent(args);
28
305244
  args.GetReturnValue().Set(env->GetNow());
29
101748
}
30
31
1667
void ScheduleTimer(const FunctionCallbackInfo<Value>& args) {
32
1667
  auto env = Environment::GetCurrent(args);
33
6668
  env->ScheduleTimer(args[0]->IntegerValue(env->context()).FromJust());
34
1667
}
35
36
1008
void ToggleTimerRef(const FunctionCallbackInfo<Value>& args) {
37
2016
  Environment::GetCurrent(args)->ToggleTimerRef(args[0]->IsTrue());
38
1008
}
39
40
27670
void ToggleImmediateRef(const FunctionCallbackInfo<Value>& args) {
41
55340
  Environment::GetCurrent(args)->ToggleImmediateRef(args[0]->IsTrue());
42
27670
}
43
44
3661
void Initialize(Local<Object> target,
45
                       Local<Value> unused,
46
                       Local<Context> context,
47
                       void* priv) {
48
3661
  Environment* env = Environment::GetCurrent(context);
49
50
3661
  env->SetMethod(target, "getLibuvNow", GetLibuvNow);
51
3661
  env->SetMethod(target, "setupTimers", SetupTimers);
52
3661
  env->SetMethod(target, "scheduleTimer", ScheduleTimer);
53
3661
  env->SetMethod(target, "toggleTimerRef", ToggleTimerRef);
54
3661
  env->SetMethod(target, "toggleImmediateRef", ToggleImmediateRef);
55
56
  target->Set(env->context(),
57
              FIXED_ONE_BYTE_STRING(env->isolate(), "immediateInfo"),
58
18305
              env->immediate_info()->fields().GetJSArray()).FromJust();
59
3661
}
60
61
62
}  // anonymous namespace
63
}  // namespace node
64
65
3596
NODE_MODULE_CONTEXT_AWARE_INTERNAL(timers, node::Initialize)