Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
vector of bool
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
#include <vector> #include <chrono> #include <iostream> int main() { constexpr std::size_t N = 128*1024*1024; const auto t1 = std::chrono::high_resolution_clock::now(); { std::vector<bool> x; x.resize(N); } const auto t2 = std::chrono::high_resolution_clock::now(); { std::vector<unsigned char> x; x.resize(N); } const auto t3 = std::chrono::high_resolution_clock::now(); const double delta1 = static_cast<double>(std::chrono::duration_cast<std::chrono::nanoseconds>(t2-t1).count()); const double delta2 = static_cast<double>(std::chrono::duration_cast<std::chrono::nanoseconds>(t3-t2).count()); std::cout << "vector<bool> " << delta1 << '\n'; std::cout << "vector<unsigned char> " << delta2 << '\n'; std::cout << "factor " << (delta1/delta2) << '\n'; return 0; }
cl.exe
Show compiler warnings
[
+
] Compiler args
[
+
]
Show input
Compilation time: 1,95 sec, absolute running time: 5,71 sec, absolute service time: 7,68 sec
edit mode
|
history
|
discussion
vector<bool> 5.44362e+09 vector<unsigned char> 1.03556e+08 factor 52.5668