Clean up sprintf, don't improve speed tho

master
Melroy van den Berg 2020-11-21 01:54:49 +01:00
parent 4e8946034a
commit 0c77212398
2 changed files with 16 additions and 11 deletions

View File

@ -68,25 +68,22 @@ void MainWindow::setupParser()
std::string filePath = exePath.append("/../../test.md");
printf("Path: %s\n", filePath.c_str());
typedef std::chrono::high_resolution_clock Time;
typedef std::chrono::milliseconds ms;
typedef std::chrono::duration<float> fsec;
cmark_node *root_node = parser->parseFile(filePath);
if (root_node != NULL) {
htmlOutput = parser->renderHTML(root_node);
typedef std::chrono::high_resolution_clock Time;
typedef std::chrono::milliseconds ms;
typedef std::chrono::duration<float> fsec;
auto t0 = Time::now();
// Render AST to scene
renderer->renderDocument(root_node);
auto t1 = Time::now();
fsec fs = t1 - t0;
ms d = std::chrono::duration_cast<ms>(fs);
printf("Duration\n");
std::cout << "ms: " << d.count() << std::endl;
std::cout << "My render: " << d.count() << " ms" << std::endl;
cmark_node_free(root_node);
}
@ -110,5 +107,16 @@ void MainWindow::resizeEvent(QResizeEvent *) {
*/
void MainWindow::setOutputToTextEdit(const QString& text)
{
typedef std::chrono::high_resolution_clock Time;
typedef std::chrono::milliseconds ms;
typedef std::chrono::duration<float> fsec;
auto htmlStart = Time::now();
textEdit->setHtml(text);
auto htmlEnd = Time::now();
fsec diff = htmlEnd - htmlStart;
ms htmlDuration = std::chrono::duration_cast<ms>(diff);
std::cout << "HTML: " << htmlDuration.count() << " ms" << std::endl;
}

View File

@ -130,8 +130,6 @@ void Renderer::renderNode(cmark_node *node, cmark_event_type ev_type)
break;
case CMARK_NODE_PARAGRAPH:
printf("p\n");
// Skip paragraph if listing is enabled
if (listLevel == 0) {
// Move to left again
@ -145,7 +143,6 @@ void Renderer::renderNode(cmark_node *node, cmark_event_type ev_type)
break;
case CMARK_NODE_TEXT: {
printf("text\n");
const QRectF rec = drawText(cmark_node_get_literal(node));
// Skip paragraph if listing is enabled
if (listLevel == 0) {