Skip to content

Commit

Permalink
feat(driver): add performance for js
Browse files Browse the repository at this point in the history
  • Loading branch information
churchill-zhang authored and hippy-actions[bot] committed May 15, 2023
1 parent 092a893 commit d89f2b0
Show file tree
Hide file tree
Showing 64 changed files with 3,911 additions and 417 deletions.
2 changes: 1 addition & 1 deletion dom/src/dom/animation/animation_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ void AnimationManager::UpdateCubicBezierAnimation(double current,
HippyValue prop_value(current);
dom_node->EmplaceStyleMapAndGetDiff(prop_it->second, prop_value, diff_value);
FOOTSTONE_DLOG(INFO) << "animation related_animation_id = " << related_animation_id
<< ", key = " << prop_it->second << ", value = " << prop_value;
<< "node id = " << dom_node->GetId() << ", key = " << prop_it->second << ", value = " << prop_value;

dom_node->SetDiffStyle(std::make_shared<
std::unordered_map<std::string, std::shared_ptr<HippyValue>>>(std::move(diff_value)));
Expand Down
20 changes: 19 additions & 1 deletion driver/js/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,22 @@ set(SOURCE_SET
src/js_driver_utils.cc
src/modules/animation_module.cc
src/modules/event_module.cc
src/modules/scene_builder.cc
src/modules/scene_builder_module.cc
src/napi/callback_info.cc
src/performance/performance.cc
src/performance/performance_entry.cc
src/performance/performance_frame_timing.cc
src/performance/performance_mark.cc
src/performance/performance_measure.cc
src/performance/performance_navigation_timing.cc
src/performance/performance_paint_timing.cc
src/performance/performance_resource_timing.cc
src/scope.cc
src/vm/js_vm.cc)
if ("${JS_ENGINE}" STREQUAL "V8")
list(APPEND SOURCE_SET
src/napi/v8/v8_ctx.cc
src/napi/v8/v8_class_definition.cc
src/napi/v8/v8_try_catch.cc
src/vm/v8/interrupt_queue.cc
src/vm/v8/memory_module.cc
Expand All @@ -171,6 +180,7 @@ if ("${JS_ENGINE}" STREQUAL "V8")
endif ()
elseif ("${JS_ENGINE}" STREQUAL "JSC")
list(APPEND SOURCE_SET
src/napi/jsc/jsc_class_definition.cc
src/napi/jsc/jsc_ctx.cc
src/napi/jsc/jsc_try_catch.cc
src/vm/jsc/jsc_vm.cc
Expand All @@ -179,6 +189,14 @@ endif ()
set(SOURCE_SET_STANDALONE
src/modules/console_module.cc
src/modules/contextify_module.cc
src/modules/performance/performance_entry_module.cc
src/modules/performance/performance_frame_timing_module.cc
src/modules/performance/performance_mark_module.cc
src/modules/performance/performance_measure_module.cc
src/modules/performance/performance_module.cc
src/modules/performance/performance_navigation_timing_module.cc
src/modules/performance/performance_paint_timing_module.cc
src/modules/performance/performance_resource_timing_module.cc
src/modules/timer_module.cc
src/modules/ui_manager_module.cc)
target_sources(${PROJECT_NAME} PRIVATE ${SOURCE_SET})
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/*
*
* Tencent is pleased to support the open source community by making
* Hippy available.
*
* Copyright (C) 2023 THL A29 Limited, a Tencent company.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

#pragma once

#include <memory>

#include "driver/napi/js_ctx_value.h"
#include "driver/performance/performance_entry.h"
#include "driver/scope.h"


namespace hippy {
inline namespace driver {
inline namespace module {

std::shared_ptr<ClassTemplate<PerformanceEntry>> RegisterPerformanceEntry(const std::weak_ptr<Scope>& weak_scope);

template<typename T>
std::vector<PropertyDefine<T>> RegisterPerformanceEntryPropertyDefine(const std::weak_ptr<Scope>& weak_scope) {
std::vector<PropertyDefine<T>> defines;
PropertyDefine<T> name_property_define;
name_property_define.name = "name";
name_property_define.getter = [weak_scope](
T* thiz,
std::shared_ptr<CtxValue>& exception) -> std::shared_ptr<CtxValue> {
auto scope = weak_scope.lock();
if (!scope) {
return nullptr;
}
auto context = scope->GetContext();
return context->CreateString(thiz->GetName());
};
defines.push_back(std::move(name_property_define));

PropertyDefine<T> entry_type_property_define;
entry_type_property_define.name = "entryType";
entry_type_property_define.getter = [weak_scope](
T* thiz,
std::shared_ptr<CtxValue>& exception) -> std::shared_ptr<CtxValue> {
auto scope = weak_scope.lock();
if (!scope) {
return nullptr;
}
auto context = scope->GetContext();
return context->CreateString(PerformanceEntry::GetEntryTypeString(thiz->GetType()));
};
defines.push_back(std::move(entry_type_property_define));

PropertyDefine<T> start_time_property_define;
start_time_property_define.name = "startTime";
start_time_property_define.getter = [weak_scope](
T* thiz,
std::shared_ptr<CtxValue>& exception) -> std::shared_ptr<CtxValue> {
auto scope = weak_scope.lock();
if (!scope) {
return nullptr;
}
auto context = scope->GetContext();
return context->CreateNumber(thiz->GetStartTime().ToEpochDelta().ToMillisecondsF());
};
defines.push_back(std::move(start_time_property_define));

PropertyDefine<T> duration_property_define;
duration_property_define.name = "duration";
duration_property_define.getter = [weak_scope](
T* thiz,
std::shared_ptr<CtxValue>& exception) -> std::shared_ptr<CtxValue> {
auto scope = weak_scope.lock();
if (!scope) {
return nullptr;
}
auto context = scope->GetContext();
return context->CreateNumber(thiz->GetDuration().ToMillisecondsF());
};
defines.push_back(std::move(duration_property_define));
return defines;
}

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
*
* Tencent is pleased to support the open source community by making
* Hippy available.
*
* Copyright (C) 2023 THL A29 Limited, a Tencent company.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

#pragma once

#include <memory>

#include "driver/napi/js_ctx_value.h"
#include "driver/performance/performance_frame_timing.h"
#include "driver/scope.h"

namespace hippy {
inline namespace driver {
inline namespace module {

std::shared_ptr<ClassTemplate<PerformanceFrameTiming>> RegisterPerformanceFrameTiming(const std::weak_ptr<Scope>& weak_scope);

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
*
* Tencent is pleased to support the open source community by making
* Hippy available.
*
* Copyright (C) 2023 THL A29 Limited, a Tencent company.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

#pragma once

#include <memory>

#include "driver/scope.h"
#include "driver/performance/performance_mark.h"
#include "driver/napi/js_ctx_value.h"


namespace hippy {
inline namespace driver {
inline namespace module {

std::shared_ptr<ClassTemplate<PerformanceMark>> RegisterPerformanceMark(const std::weak_ptr<Scope>& weak_scope);

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
*
* Tencent is pleased to support the open source community by making
* Hippy available.
*
* Copyright (C) 2023 THL A29 Limited, a Tencent company.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

#pragma once

#include <memory>

#include "driver/napi/js_ctx_value.h"
#include "driver/performance/performance_measure.h"
#include "driver/scope.h"

namespace hippy {
inline namespace driver {
inline namespace module {

std::shared_ptr<ClassTemplate<PerformanceMeasure>> RegisterPerformanceMeasure(const std::weak_ptr<Scope>& weak_scope);

}
}
}
38 changes: 38 additions & 0 deletions driver/js/include/driver/modules/performance/performance_module.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
*
* Tencent is pleased to support the open source community by making
* Hippy available.
*
* Copyright (C) 2023 THL A29 Limited, a Tencent company.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

#pragma once

#include <memory>

#include "driver/scope.h"
#include "driver/napi/js_ctx_value.h"

namespace hippy {
inline namespace driver {
inline namespace module {

std::shared_ptr<ClassTemplate<Performance>> RegisterPerformance(const std::weak_ptr<Scope>& weak_scope);

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
*
* Tencent is pleased to support the open source community by making
* Hippy available.
*
* Copyright (C) 2023 THL A29 Limited, a Tencent company.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

#pragma once

#include <memory>

#include "driver/scope.h"
#include "driver/napi/js_ctx_value.h"
#include "driver/performance/performance_navigation_timing.h"

namespace hippy {
inline namespace driver {
inline namespace module {

std::shared_ptr<ClassTemplate<PerformanceNavigationTiming>> RegisterPerformanceNavigationTiming(const std::weak_ptr<Scope>& weak_scope);

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
*
* Tencent is pleased to support the open source community by making
* Hippy available.
*
* Copyright (C) 2023 THL A29 Limited, a Tencent company.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

#pragma once

#include <memory>

#include "driver/napi/js_ctx_value.h"
#include "driver/performance/performance_paint_timing.h"
#include "driver/scope.h"

namespace hippy {
inline namespace driver {
inline namespace module {

std::shared_ptr<ClassTemplate<PerformancePaintTiming>> RegisterPerformancePaintTiming(const std::weak_ptr<Scope>& weak_scope);

}
}
}
Loading

0 comments on commit d89f2b0

Please sign in to comment.