24 template <
typename Expr,
typename R>
43 explicit timed_expr(Expr l) : value(std::forward<Expr>(l)) {
61 bool alias(
const E& other)
const noexcept {
62 return value.alias(other);
73 auto start_time = etl::timer_clock::now();
77 auto end_time = etl::timer_clock::now();
78 auto duration = std::chrono::duration_cast<
clock_resolution>(end_time - start_time);
80 std::cout <<
"timed(=): " << value <<
" took " << duration.count() << resolution_to_string<clock_resolution>() << std::endl;
89 auto start_time = etl::timer_clock::now();
91 value.assign_add_to(lhs);
93 auto end_time = etl::timer_clock::now();
94 auto duration = std::chrono::duration_cast<
clock_resolution>(end_time - start_time);
96 std::cout <<
"timed(+=): " << value <<
" took " << duration.count() << resolution_to_string<clock_resolution>() << std::endl;
103 template <
typename L>
105 auto start_time = etl::timer_clock::now();
107 value.assign_sub_to(lhs);
109 auto end_time = etl::timer_clock::now();
110 auto duration = std::chrono::duration_cast<
clock_resolution>(end_time - start_time);
112 std::cout <<
"timed(-=): " << value <<
" took " << duration.count() << resolution_to_string<clock_resolution>() << std::endl;
119 template <
typename L>
121 auto start_time = etl::timer_clock::now();
123 value.assign_mul_to(lhs);
125 auto end_time = etl::timer_clock::now();
126 auto duration = std::chrono::duration_cast<
clock_resolution>(end_time - start_time);
128 std::cout <<
"timed(*=): " << value <<
" took " << duration.count() << resolution_to_string<clock_resolution>() << std::endl;
135 template <
typename L>
137 auto start_time = etl::timer_clock::now();
139 value.assign_div_to(lhs);
141 auto end_time = etl::timer_clock::now();
142 auto duration = std::chrono::duration_cast<
clock_resolution>(end_time - start_time);
144 std::cout <<
"timed(/=): " << value <<
" took " << duration.count() << resolution_to_string<clock_resolution>() << std::endl;
151 template <
typename L>
153 auto start_time = etl::timer_clock::now();
155 value.assign_mod_to(lhs);
157 auto end_time = etl::timer_clock::now();
158 auto duration = std::chrono::duration_cast<
clock_resolution>(end_time - start_time);
160 std::cout <<
"timed(%=): " << value <<
" took " << duration.count() << resolution_to_string<clock_resolution>() << std::endl;
170 return os <<
"timed(" << expr.value <<
")";
178 template <
typename Expr,
typename R>
R clock_resolution
The clock resolution.
Definition: timed_expr.hpp:26
Contains traits for wrapper expressions.
bool alias(const E &other) const noexcept
Test if this expression aliases with the given expression.
Definition: timed_expr.hpp:61
friend std::ostream & operator<<(std::ostream &os, const timed_expr &expr)
Prints the type of the timed expression to the stream.
Definition: timed_expr.hpp:169
Traits to get information about ETL types.
Definition: tmp.hpp:68
Root namespace for the ETL library.
Definition: adapter.hpp:15
void assign_mul_to(L &&lhs) const
Multiply the given left-hand-side expression.
Definition: timed_expr.hpp:120
void assign_to(L &&lhs) const
Assign to the given left-hand-side expression.
Definition: timed_expr.hpp:72
timed_expr(Expr l)
Construt a new timed expression around the given ETL expression.
Definition: timed_expr.hpp:43
void assign_mod_to(L &&lhs) const
Modulo the given left-hand-side expression.
Definition: timed_expr.hpp:152
Expr expr_t
The wrapped expression type.
Definition: timed_expr.hpp:27
value_t< Expr > value_type
The value type.
Definition: timed_expr.hpp:28
void assign_add_to(L &&lhs) const
Add to the given left-hand-side expression.
Definition: timed_expr.hpp:88
void assign_sub_to(L &&lhs) const
Sub from the given left-hand-side expression.
Definition: timed_expr.hpp:104
void assign_div_to(L &&lhs) const
Divide the given left-hand-side expression.
Definition: timed_expr.hpp:136
A wrapper for expressions that need to be timed.
Definition: timed_expr.hpp:25
typename decay_traits< E >::value_type value_t
Traits to extract the value type out of an ETL type.
Definition: tmp.hpp:81
Traits for wrapper expressions.
Definition: wrapper_traits.hpp:21