Skip to content
This repository has been archived by the owner on Dec 28, 2021. It is now read-only.

Add profiling mode to GUI #1546

Merged
merged 36 commits into from
Jun 10, 2021
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
b55d610
Add profiling mode
s9ferech May 6, 2021
26984e6
Merge branch 'develop' into wip/fr/profiling
s9ferech May 6, 2021
4d35256
Include profiling shortcut in documentation
s9ferech May 6, 2021
798defb
Display profiling indicators in front of edges
s9ferech May 6, 2021
c02c45e
Fix formatting of CHANGELOG.md
s9ferech May 6, 2021
332d3cd
Move definition of ExecutionStatuses
s9ferech May 6, 2021
54004d8
Fix formatting
s9ferech May 7, 2021
1214dc7
Fix formatting
s9ferech May 7, 2021
dff8a4f
Fix formatting
s9ferech May 7, 2021
e89a093
Address some review comments
s9ferech May 7, 2021
b9b5a9d
Merge branch 'wip/fr/profiling' of https://github.com/enso-org/ide in…
s9ferech May 7, 2021
9e7e277
Remove identical conversion
s9ferech May 7, 2021
e264d8f
Disable syntax highlighting in profiling mode
s9ferech May 11, 2021
cf84b4a
Make requested changes
s9ferech May 16, 2021
3543f4c
Fix placement of profiling indicator
s9ferech May 17, 2021
a0c4b77
Gray out JS visualizations in profiling mode
s9ferech May 17, 2021
d76a471
Merge branch 'develop' into wip/fr/profiling
s9ferech May 17, 2021
7bd0376
Document `set_grayscale` on `DomScene`
s9ferech May 17, 2021
030fa56
Solve linting errors
s9ferech May 17, 2021
da1bc98
Make some of the requested changes
s9ferech May 20, 2021
c3cd76a
Make requested changes
s9ferech May 25, 2021
7aeab47
Fix FRP initializations
s9ferech May 25, 2021
659a68b
Rename running time label to profiling label
s9ferech May 25, 2021
c1c503e
Update edge colors less often
s9ferech May 26, 2021
ea12ada
Fix some color initializations and updates
s9ferech May 26, 2021
24a6001
Merge branch 'develop' into wip/fr/profiling
s9ferech May 26, 2021
bcfa122
Fix field order in struct constructions
s9ferech May 26, 2021
873c5c4
Fix text color when edited in profiling mode
s9ferech May 26, 2021
3ff04b5
Merge branch 'develop' into wip/fr/profiling
s9ferech May 27, 2021
4f19a29
Update for renamed definitions
s9ferech May 27, 2021
fdee41a
Fix cursor color after view mode switch
s9ferech May 27, 2021
1073d1a
Rename "mode" to "view mode"
s9ferech May 27, 2021
25ce8b0
Update CHANGELOG.md
s9ferech May 28, 2021
1a2917d
Make requested changes
s9ferech Jun 8, 2021
e4b6784
Merge branch 'develop' into wip/fr/profiling
s9ferech Jun 8, 2021
b329223
Merge branch 'develop' into wip/fr/profiling
s9ferech Jun 10, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#### EnsoGL (rendering engine)


<br/>![Bug Fixes](/docs/assets/tags/bug_fixes.svg)

#### Visual Environment
Expand Down
2 changes: 2 additions & 0 deletions docs/product/shortcuts.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ further investigation.
| <kbd>ctrl</kbd>+<kbd>q</kbd> | Close the application (Linux) |
| <kbd>alt</kbd>+<kbd>F4</kbd> | Close the application (MacOS, Windows, Linux) |
| <kbd>ctrl</kbd>+<kbd>w</kbd> | Close the application (Windows, Linux) |
| :warning: <kbd>ctrl</kbd>+<kbd>p</kbd> | Toggle profiling mode |
s9ferech marked this conversation as resolved.
Show resolved Hide resolved


#### Navigation
Expand Down Expand Up @@ -107,6 +108,7 @@ further investigation.
| <kbd>meta</kbd> + <kbd>z</kbd> | Zoom into selection if available in visualization. |



#### Debug
| Shortcut | Action |
| -------- | ------ |
Expand Down
6 changes: 6 additions & 0 deletions src/rust/ensogl/lib/theme/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,12 @@ define_themes! { [light:0, dark:1]
stripe_width = 10.0 , 10.0;
stripe_angle = 45.0 , 45.0;
}
profiling {
lightness = code::types::lightness , code::types::lightness;
chroma = code::types::chroma , code::types::chroma;
min_hue = 0.38 , 0.38;
max_hue = 0.07 , 0.07;
s9ferech marked this conversation as resolved.
Show resolved Hide resolved
}
}
visualization {
background = graph_editor::node::background , graph_editor::node::background;
Expand Down
76 changes: 62 additions & 14 deletions src/rust/ide/view/graph-editor/src/component/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ pub mod output;
pub mod error;
#[deny(missing_docs)]
pub mod vcs;
mod profiling_indicator;
s9ferech marked this conversation as resolved.
Show resolved Hide resolved

pub use error::Error;
pub use expression::Expression;

use crate::prelude::*;

use profiling_indicator::ProfilingIndicator;
use crate::Mode as EditorMode;
s9ferech marked this conversation as resolved.
Show resolved Hide resolved
s9ferech marked this conversation as resolved.
Show resolved Hide resolved
use crate::component::visualization;
use crate::tooltip;
use crate::Type;
Expand Down Expand Up @@ -50,10 +53,10 @@ pub const HEIGHT : f32 = 28.0;
pub const PADDING : f32 = 40.0;
pub const RADIUS : f32 = 14.0;

const INFINITE : f32 = 99999.0;
const ERROR_VISUALIZATION_SIZE : (f32,f32) = visualization::container::DEFAULT_SIZE;
const INFINITE : f32 = 99999.0;
const ERROR_VISUALIZATION_SIZE : (f32,f32) = visualization::container::DEFAULT_SIZE;

const VISUALIZATION_OFFSET_Y : f32 = -120.0;
const VISUALIZATION_OFFSET_Y : f32 = -120.0;

const VIS_PREVIEW_ONSET_MS : f32 = 3000.0;
const ERROR_PREVIEW_ONSET_MS : f32 = 0000.0;
Expand Down Expand Up @@ -205,6 +208,24 @@ pub mod error_shape {



// ========================
// === Execution Status ===
// ========================

#[derive(Debug,Copy,Clone)]
pub enum ExecutionStatus {
Running,
Finished { duration: f32 }
}

impl Default for ExecutionStatus {
fn default() -> Self {
ExecutionStatus::Running
}
}
s9ferech marked this conversation as resolved.
Show resolved Hide resolved



// ==============
// === Crumbs ===
// ==============
Expand Down Expand Up @@ -256,11 +277,15 @@ ensogl::define_endpoints! {
/// Set the expression USAGE type. This is not the definition type, which can be set with
/// `set_expression` instead. In case the usage type is set to None, ports still may be
/// colored if the definition type was present.
set_expression_usage_type (Crumbs,Option<Type>),
set_output_expression_visibility (bool),
set_vcs_status (Option<vcs::Status>),
set_expression_usage_type (Crumbs,Option<Type>),
set_output_expression_visibility (bool),
set_vcs_status (Option<vcs::Status>),
/// Indicate whether preview visualisations should be delayed or immediate.
quick_preview_vis (bool),
quick_preview_vis (bool),
set_editor_mode (EditorMode),
set_profiling_min_global_duration (f32),
set_profiling_max_global_duration (f32),
set_execution_status (ExecutionStatus),
}
Output {
/// Press event. Emitted when user clicks on non-active part of the node, like its
Expand Down Expand Up @@ -359,6 +384,7 @@ pub struct NodeModel {
pub background : background::View,
pub drag_area : drag_area::View,
pub error_indicator : error_shape::View,
pub profiling_indicator : ProfilingIndicator,
pub input : input::Area,
pub output : output::Area,
pub visualization : visualization::Container,
Expand Down Expand Up @@ -395,13 +421,15 @@ impl NodeModel {
let drag_logger = Logger::sub(&logger,"drag_area");
let error_indicator_logger = Logger::sub(&logger,"error_indicator");

let error_indicator = error_shape::View::new(&error_indicator_logger);
let backdrop = backdrop::View::new(&main_logger);
let background = background::View::new(&main_logger);
let drag_area = drag_area::View::new(&drag_logger);
let vcs_indicator = vcs::StatusIndicator::new(app);
let display_object = display::object::Instance::new(&logger);
let error_indicator = error_shape::View::new(&error_indicator_logger);
let profiling_indicator = ProfilingIndicator::new(app);
s9ferech marked this conversation as resolved.
Show resolved Hide resolved
let backdrop = backdrop::View::new(&main_logger);
let background = background::View::new(&main_logger);
let drag_area = drag_area::View::new(&drag_logger);
let vcs_indicator = vcs::StatusIndicator::new(app);
let display_object = display::object::Instance::new(&logger);

display_object.add_child(&profiling_indicator);
display_object.add_child(&drag_area);
display_object.add_child(&backdrop);
display_object.add_child(&background);
Expand Down Expand Up @@ -432,7 +460,8 @@ impl NodeModel {

let app = app.clone_ref();
Self {app,display_object,logger,backdrop,background,drag_area,output,input,visualization
,error_visualization,action_bar,error_indicator,vcs_indicator,style}.init()
,error_visualization,profiling_indicator,action_bar,error_indicator,vcs_indicator,style}
.init()
}

pub fn get_crumbs_by_id(&self, id:ast::Id) -> Option<Crumbs> {
Expand Down Expand Up @@ -473,12 +502,14 @@ impl NodeModel {
self.backdrop.size.set(padded_size);
self.background.size.set(padded_size);
self.drag_area.size.set(padded_size);
self.profiling_indicator.set_size(padded_size);
self.error_indicator.size.set(padded_size);
self.vcs_indicator.set_size(padded_size);
self.backdrop.mod_position(|t| t.x = width/2.0);
self.background.mod_position(|t| t.x = width/2.0);
self.drag_area.mod_position(|t| t.x = width/2.0);

self.profiling_indicator.set_position_x(width/2.0);
self.error_indicator.set_position_x(width/2.0);
self.vcs_indicator.set_position_x(width/2.0);

Expand Down Expand Up @@ -587,6 +618,12 @@ impl Node {
out.source.skip <+ action_bar.action_skip;
out.source.freeze <+ action_bar.action_freeze;
eval out.hover ((t) action_bar.set_visibility(t));


// === Editor Mode ===

model.input.set_editor_mode <+ frp.set_editor_mode;
model.profiling_indicator.set_editor_mode <+ frp.set_editor_mode;
}


Expand Down Expand Up @@ -663,6 +700,17 @@ impl Node {

}

// === Profiling Indicator ===

frp::extend! { network
model.profiling_indicator.set_min_global_duration
<+ frp.set_profiling_min_global_duration;
model.profiling_indicator.set_max_global_duration
<+ frp.set_profiling_max_global_duration;
model.profiling_indicator.set_execution_status <+ frp.set_execution_status;
}


frp::extend! { network

// === Color Handling ===
Expand Down
45 changes: 35 additions & 10 deletions src/rust/ide/view/graph-editor/src/component/node/input/area.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use crate::Type;
use crate::component::type_coloring;
use crate::node::input::port;
use crate::node;
use crate::Mode as EditorMode;
s9ferech marked this conversation as resolved.
Show resolved Hide resolved



Expand Down Expand Up @@ -193,6 +194,8 @@ ensogl::define_endpoints! {
/// if any. It is used to highlight ports if they are missing type information or if their
/// types are polymorphic.
set_ports_active (bool,Option<Type>),

set_editor_mode(EditorMode),
}

Output {
Expand All @@ -206,6 +209,7 @@ ensogl::define_endpoints! {
on_port_hover (Switch<Crumbs>),
on_port_type_change (Crumbs,Option<Type>),
on_background_press (),
editor_mode (EditorMode),
}
}

Expand Down Expand Up @@ -387,6 +391,10 @@ impl Area {
// === Expression Type ===

eval frp.set_expression_usage_type (((a,b)) model.set_expression_usage_type(a,b));


// === Editor Mode ===
s9ferech marked this conversation as resolved.
Show resolved Hide resolved
frp.output.source.editor_mode <+ frp.set_editor_mode;
}

Self {model,frp}
Expand Down Expand Up @@ -592,11 +600,17 @@ impl Area {

let port_shape_hover = port_shape.hover.clone_ref();
pointer_style_out <- mouse_out.map(|_| default());
pointer_style_over <- map3(&mouse_over,&frp.set_ports_active,&port.tp,
move |_,(_,edge_tp),port_tp| {
let tp = port_tp.as_ref().or_else(||edge_tp.as_ref());
let color = tp.map(|tp| type_coloring::compute(tp,&styles));
let color = color.unwrap_or(any_type_sel_color);
pointer_style_over <- map4
(&mouse_over,&frp.set_ports_active,&port.tp,&frp.editor_mode,
move |_,(_,edge_tp),port_tp,editor_mode| {
let color = match editor_mode {
EditorMode::Normal => {
let tp = port_tp.as_ref().or_else(||edge_tp.as_ref());
let color = tp.map(|tp| type_coloring::compute(tp,&styles));
color.unwrap_or(any_type_sel_color)
},
EditorMode::Profiling => any_type_sel_color
};
cursor::Style::new_highlight(&port_shape_hover,padded_size,Some(color))
}
);
Expand Down Expand Up @@ -703,11 +717,22 @@ impl Area {
if let Some(port_shape) = &node.payload.shape {
frp::extend! { port_network
port_tp <- all(&frp.set_hover,&frp.tp)._1();
new_viz_color <- all_with(&port_tp,&frp.set_connected,f!([styles]
(port_tp,(is_connected,edge_tp)) {
let tp = port_tp.as_ref().or_else(||edge_tp.as_ref());
let color = select_color(&styles,tp);
if *is_connected {color} else { color::Lcha::transparent() }
new_viz_color <- all_with3
(&port_tp,&frp.set_connected,&self.editor_mode,
f!([styles](port_tp,(is_connected,edge_tp),editor_mode) {
if *is_connected {
match editor_mode {
EditorMode::Normal => {
let tp = port_tp.as_ref().or_else(||edge_tp.as_ref());
select_color(&styles,tp)
},
EditorMode::Profiling => {
styles.get_color(theme::code::types::any::selection).into()
s9ferech marked this conversation as resolved.
Show resolved Hide resolved
}
}
} else {
color::Lcha::transparent()
}
}
));
viz_color.target <+ new_viz_color;
Expand Down