<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

 <title>acfreeman dev</title>
 <link href="https://acfreeman.dev/atom.xml" rel="self"/>
 <link href="https://acfreeman.dev/"/>
 <updated>2026-08-31T15:37:29+00:00</updated>
 <id>https://acfreeman.dev</id>
 <author>
   <name></name>
   <email></email>
 </author>

 
 <entry>
   <title>How to Give an Academic Presentation</title>
   <link href="https://acfreeman.dev/2026/08/14/presentations"/>
   <updated>2026-08-14T00:00:00+00:00</updated>
   <id>https://acfreeman.dev/2026/08/14/presentations</id>
   <content type="html">&lt;p&gt;Public speaking is an art that takes a lot of practice to get good at. Being a good public speaker is what separates the wheat from the chaff, so it’s crucial that you gain this skill during your academic journey. Here are some guidelines.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Never read from a script.&lt;/strong&gt; It’s the most frustrating thing in the world as an audience member. If you’re reading from a script, why don’t I just read that same script myself and save us all some time? This breaks all engagement with the audience.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Don’t memorize a script.&lt;/strong&gt; In the same vein, you shouldn’t just memorize a written-out script. You need to be able to think dynamically. It’s okay to have a few words or phrases in your slideshow notes, but these should just help accelerate your context switching.
    &lt;ol&gt;
      &lt;li&gt;Items 1 and 2 are particular temptations for non-native English speakers. I truly empathize with that. However, if you never force yourself into this discomfort, you’ll never learn and improve. You have to rip the band-aid off.&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Avoid “um.”&lt;/strong&gt; This is the hardest one for me (and most people). It takes an intense amount of effort to avoid filler words. But if you can achieve that, or at least minimize the usage to a handful of times, you will stand out.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Make eye contact.&lt;/strong&gt; Look audience members in the eye. Don’t look at any individual for too long, though, because that’s creepy.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Use gestures, and refer to the slides/whiteboard directly.&lt;/strong&gt; Your body language should exude confidence. Laser pointers can be helpful if you don’t overuse them.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Make a joke or two.&lt;/strong&gt; It helps keep audience members engaged.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Use dynamic inflection.&lt;/strong&gt; Monotone speakers are boring.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Speak loudly.&lt;/strong&gt; You should be loud enough for the people in the back of the room to hear you clearly.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Slow down.&lt;/strong&gt; When you’re nervous, the tendency is to talk too fast. Then you realize that everybody knows you’re nervous, and then you talk faster. It’s a vicious cycle. Slow down and breathe.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Test out the A/V equipment before you start.&lt;/strong&gt; There’s always time to test out the presentation equipment before your presentation’s start time. Take advantage of that opportunity to sort out any kinks. You don’t want to be that person who gets up there and can’t get their laptop’s display output to be detected. It’s awkward.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Have a backup plan.&lt;/strong&gt; If your laptop were to be dropped from a 10-story building right before your presentation, what would you do? Have a copy of your presentation hosted in the cloud, somewhere easy to access. Check with a friend or conference organizer to make sure that you can borrow someone’s equipment in case something happens.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Don’t go over time.&lt;/strong&gt; If it’s a formal, one-off presentation, you have a specific time limit. In this case, you should &lt;strong&gt;practice&lt;/strong&gt; and time yourself to make sure that you respect the time limit. Leave a few minutes of buffer for questions. If you’re doing a group presentation, each person should have individual time limits that are agreed upon, and you should hold each other accountable. My pet peeve at research conferences is when everybody goes 5-10 minutes over time. Over the course of a whole session, this throws off the entire schedule. Therefore, it’s an act of disrespect to all the other presenters and attendees.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Be prepared for questions.&lt;/strong&gt; You could give an amazing presentation, but if you can’t answer questions about the content, it leaves a sour taste in the mouth at the end. You should be able to explain any detail in your presentation at a higher level of detail. If somebody asks a question that requires a very lengthy answer, or if there’s a back-and-forth of several follow-up questions, try to summarize your answer but offer to discuss it privately afterwards. My go-to phrase is, “I’d be happy to continue this discussion offline.” This respects the time limit.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Know your audience.&lt;/strong&gt; It’s okay to assume a certain level of background knowledge if you’re talking to an audience of experts, but not if you’re talking to a general audience. You need to adapt your material to the audience. But still, don’t tune the entire presentation for the average. A good rule of thumb that I heard once is the 70/20/10 rule: 70% of your presentation should be understood by everybody in the audience; 20% should be understood by a handful of expert audience members; and 10% should be understood by &lt;em&gt;nobody&lt;/em&gt; in the audience. This last 10% needs to still be accurate, obviously, but the idea is that you present some small amount of material that is new to everyone, and that encourages them to do further exploration on your topic afterwards. This is what leads to interesting follow-up questions. In a conference setting, the sign of an excellent presentation is if you compel people to actually go read your paper.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Define most acronyms/initialisms early on, and consider verbally repeating the definitions later on.&lt;/strong&gt; This is part of knowing your audience. You don’t want an overly jargony presentation, but you do want to use acronyms/initialisms when they greatly increase the efficiency of communication. For example, if I’m giving an hour-long lecture on TCP to undergraduates, I’ll explicitly say “Transmission Control Protocol” maybe a dozen times. If I’m giving a presentation on video streaming to a group of experts, I’ll never define TCP explicitly. If it’s a mixed audience, I’ll land somewhere in the middle, writing out the acronym on the slides and saying it once or twice.&lt;/li&gt;
&lt;/ol&gt;
</content>
 </entry>
 
 <entry>
   <title>Graduate Student Expectations</title>
   <link href="https://acfreeman.dev/2025/07/22/gradcontract"/>
   <updated>2025-07-22T00:00:00+00:00</updated>
   <id>https://acfreeman.dev/2025/07/22/gradcontract</id>
   <content type="html">&lt;p&gt;This document lays out some of my expectations for a computer science graduate student working under my advisement. It also serves as a sort of guide to navigating graduate school, if you’re not sure what’s in store. The goal here is not to intimidate you or worry you, but rather to ease the transition. I know it’s hard! I was in your shoes not too long ago, and my hope is that this will make things easier.&lt;/p&gt;

&lt;p&gt;To help prospective applicants have a better idea of what they’d be getting into with me, I’m sharing this on my public blog as well. I also recommend that you read the general advice I offer &lt;a href=&quot;https://acfreeman.dev/2024/05/10/phdadvice&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h1 id=&quot;the-first-two-years&quot;&gt;The first two years&lt;/h1&gt;
&lt;p&gt;Many of the guidelines here will be geared toward PhD students, since they do a lot more research. The first two years of your graduate life, however, will be much the same between PhD and on-site Master’s students.&lt;/p&gt;

&lt;p&gt;You’ll have to take several classes during this period: approximately two 3-credit courses per semester.&lt;/p&gt;

&lt;p&gt;Overall, your baseline goal in your courses is this: &lt;strong&gt;get decently good grades&lt;/strong&gt;. That’s it. You don’t have to get perfect grades.&lt;/p&gt;

&lt;p&gt;This can be a stark change from your experience in undergrad or a prior Master’s degree. The reason is that &lt;em&gt;every hour of time you spend on a course is one less hour that you’re spending on research&lt;/em&gt;. If you can spend 5 hours per week on a course and get a A-, that’s better than spending 15 hours per week on a course and getting an A. My expectation is that you’ll have an A- in at least four courses.&lt;/p&gt;

&lt;p&gt;Now, you should use some discretion in deciding if certain courses are worth more effort and time for you. For example, I would expect you to get an A in a data compression course, since that’s a core are of research you will likely engage in. But I wouldn’t be bent out of shape if you got a B+ in an algorithms course.&lt;/p&gt;

&lt;p&gt;Although courses take some time, your focus should already be on your research. Spend time with me discussing ideas, so we can start to identify a solid project for you to spend the next few years on.&lt;/p&gt;

&lt;p&gt;After the third semester, you’ll have to do your &lt;a href=&quot;https://www.ecs.baylor.edu/students-academics/degree-programs/graduate-degrees/doctor-philosophy-computer-science/degree&quot;&gt;qualifying exams&lt;/a&gt;, or “quals,” as some people call them. This is where you can be rewarded for strong grades, as you can avoid the breadth exam by having an A- or greater in a few courses. The depth exam, in contrast, focuses on your understanding of your chosen research topic, as we assess your preparedness to begin full-time research.&lt;/p&gt;

&lt;h1 id=&quot;the-last-three-ish-years&quot;&gt;The last three-ish years&lt;/h1&gt;
&lt;p&gt;Once you’re done with courses, research is your one and only focus. You may still have some distractions through TA work (below) if there’s not relevant RA funding available, but your efforts as a TA will not be considered when your dissertation is being evaluated.&lt;/p&gt;

&lt;p&gt;At this stage, you’ll need to organize your dissertation committee according to &lt;a href=&quot;https://graduate.baylor.edu/student-resources/completing-your-degree/dissertation-thesis-overview/committee-and-defense&quot;&gt;these guidelines&lt;/a&gt;. In addition to me, you should enlist at least three (my preference is four) other professors to evaluate your dissertation progress.&lt;/p&gt;

&lt;p&gt;Towards the end of year 3 (or whenever you and I feel that you’re ready), you should submit your dissertation proposal. This will consist of a clear research question or thesis statement, a literature review, a discussion of your progress so far, and a thorough plan for what you intend to accomplish (and how). You’ll present this proposal to your committee, and once you pass you’ll officially be considered a PhD “candidate.”&lt;/p&gt;

&lt;p&gt;From there, it’s full steam ahead. You should meet with your committee at least once every 6 months (i.e., once per semester) to report your progress and receive feedback. You’ll be working on papers that will get you closer to your dissertation goals, and weaving those papers into one giant, long dissertation document. Once you and I agree that you’ve made sufficient progress, you’ll submit your dissertation to your committee and arrange a meeting to defend it.&lt;/p&gt;

&lt;p&gt;Your defense will involve an hour-long presentation, public questioning, private questioning from your committee members, and then private deliberation. If you pass, you’ll be able to include three more letters in your email signature! You’ll also be able to breathe for a minute and move on to the next phase of your career.&lt;/p&gt;

&lt;h1 id=&quot;grad-school-is-a-job-and-a-marathon&quot;&gt;Grad school is a job… and a marathon&lt;/h1&gt;
&lt;p&gt;You should work roughly 40 hours per week, just like you would in a normal job. You should be proactive about scheduling regular meetings (once per week, except on holidays) with me to discuss your progress, and you should attend the weekly lab meetings.&lt;/p&gt;

&lt;p&gt;Teaching assistants (TAs) are typically assigned 20 hours per week. If you’re working as a TA, keep a log of your hours. You should never work more than 20 hours in a week on a TA assignment. If you do, that means your professor is assigning you too much work. You should let me know, and I’ll talk to them about it for you. Research assistants (RAs) are also assigned in 20-hour blocks, but it’s not a bad thing if you go over 20 hours. Your work as an RA directly gets you closer to graduation.&lt;/p&gt;

&lt;p&gt;Don’t work 60-hour weeks or anything ridiculous. There will occasionally be a day where you have to stay up late to meet a deadline, but this should never be the norm. In fact, if you take a careful approach to your time management, it’s possible to avoid late nights altogether. In the same vein, you should try to avoid working on weekends. You’ll come back on Monday refreshed and brimming with new ideas.&lt;/p&gt;

&lt;p&gt;You can even take extended breaks, so long as they’re reasonable and you let me know in advance. Enjoy time with family over Thanksgiving and Christmas. Go on a big road trip during the summer. If you attend a conference in a fun location, use some of your savings to travel around the area afterwards. These are all things that I did as a PhD student, and I was a happier man for it.&lt;/p&gt;

&lt;p&gt;You have a precious balance to maintain in your brain chemistry, spiritual and physical health, relationships, and degree progress. Plan ahead, make steady progress, and remember to stop and smell the roses.&lt;/p&gt;

&lt;h1 id=&quot;publish-or-perish&quot;&gt;Publish or perish?&lt;/h1&gt;
&lt;p&gt;I don’t have any firm requirements for publications, because I know that the reviewer lottery is sometimes particularly unfair. However, a good rule of thumb is this:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;By the end of Year 1, have one minor 1st-author publication, or be a 2nd+ author on a major publication from the lab&lt;/li&gt;
  &lt;li&gt;One major 1st-author publication each of the following years&lt;/li&gt;
  &lt;li&gt;One 1st- or 2nd-author journal publication by the end&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;“Major” publications will typically be full-length papers in esteemed conferences or journals. “Minor” publications will be shorter papers, or full-length papers in not-so-good conferences. As your advisor, I can tell you what publication venues are good or “meh,” and my opinions won’t always align with the public rankings (which don’t really encompass multimedia very well).&lt;/p&gt;

&lt;h1 id=&quot;other-expectations&quot;&gt;Other expectations&lt;/h1&gt;
&lt;p&gt;These are “nice-to-haves” during your PhD that will greatly help you prepare to transition out grad school and start your career as an independent researcher:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Deliver three presentations at conferences&lt;/li&gt;
  &lt;li&gt;Write a substantial portion of one grant proposal&lt;/li&gt;
  &lt;li&gt;Work at least one research-focused internship&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;im-on-your-side&quot;&gt;I’m on your side&lt;/h1&gt;
&lt;p&gt;It’s my job to advocate for you to other faculty. It’s my job to help you get published. It’s my job to help you get a job yourself. My success is largely measured by your success.&lt;/p&gt;

&lt;p&gt;If I give you any negative feedback, it’s because I’m trying to help you improve and succeed. Every week of grad school, you should be able to think back to the previous week and say, “I know more than I did, and I’m better than I was.”&lt;/p&gt;

&lt;h1 id=&quot;if-its-really-not-working&quot;&gt;If it’s really not working…&lt;/h1&gt;
&lt;p&gt;If, for whatever reason, I don’t think that you have any chance of being successful as my student, I will let you know in a kind but clear way. That’s my commitment to you. This is important, because it’s better to let you know early than allow you to flounder and waste your time.&lt;/p&gt;

&lt;p&gt;On the other hand, you might also find yourself dissatisfied working with me. I expect you to let me know that as well. Maybe you don’t like my style, or you decide you’re not interested in the research topics available. That’s okay! It’s always possible to change your advisor, but it’s best to realize this need early on (within the first year or two), so that your degree progress isn’t delayed.&lt;/p&gt;

&lt;h1 id=&quot;personal-notes-for-my-students&quot;&gt;Personal notes for my students&lt;/h1&gt;
&lt;p&gt;Every advisor has his own idiosyncrasies and sources of irritation. I hope that I can be self-aware enough to be forthcoming of what mine are. To a certain extent, recognizing and accommodating these quirks can make life easier. You should also feel entitled, though, to call me out when I’m being unreasonable. I’m a sinner just like you, and I don’t always get it right.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Don’t use “code” as a verb unless you’re talking about compression.&lt;/strong&gt; You should instead say e.g., “program” or “write code.”&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Skip the formalities in your communication.&lt;/strong&gt; Cut to the chase—we don’t have all day here! Communication should be focused and to-the-point of the business at hand. If there’s a lot of fluff, I won’t read it in detail. That’s &lt;em&gt;not&lt;/em&gt; to say we won’t be personable. Rather, I’d prefer if you talk to me the same way you would one of your fellow grad students, rather than someone special. You should call me by my first name.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;If possible, send me a Teams DM instead of an email.&lt;/strong&gt; Direct messages are much better for quick and interactive conversations. Emails should be more focused on separate tasks. For example, if you have a question about the methodology in a paper you’re reading, send me a DM. I can probably get back to you within a couple of hours during the work day. If you need me to sign some paperwork and it’s not due for two more weeks, send me an email. I’ll leave it flagged in my inbox until I have time to get to it.&lt;/p&gt;

    &lt;p&gt;Also, 95% of the emails I get are completely unimportant. It’s easy for your message to get lost in the noise. A DM increases the likelihood that I’ll actually see it.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;
</content>
 </entry>
 
 <entry>
   <title>What I Want from an Operating System</title>
   <link href="https://acfreeman.dev/2024/07/25/operatingsystems"/>
   <updated>2024-07-25T00:00:00+00:00</updated>
   <id>https://acfreeman.dev/2024/07/25/operatingsystems</id>
   <content type="html">&lt;p&gt;Back in middle school I got my &lt;a href=&quot;https://www.cnet.com/reviews/dell-inspiron-i545s-1476n-review/&quot;&gt;first computer&lt;/a&gt;. It shipped with Windows Vista, an operating system infamous for its high resource demands and sluggish performance. When Windows 7 released, I didn’t want to spend $100 (that I probably didn’t have) just to get some more performance.&lt;/p&gt;

&lt;p&gt;In my search for alternatives, I decided to dabble with Ubuntu Linux. I was a bit worried that I would mess up the installation, so I asked my dad for permission. To help convince him, I lied and said that a friend of mine from school had installed it recently. This white lie was probably the furthest that my teenage rebellion went, and I have since told my father and received his forgiveness along with some good laughs.&lt;/p&gt;

&lt;p&gt;In high school, I built my first computer, an awful machine running an &lt;a href=&quot;https://en.wikipedia.org/wiki/AMD_FX&quot;&gt;AMD FX&lt;/a&gt; “8-core” CPU (that was, in reality, 4 very bad cores). I didn’t leave enough room in my budget for a Windows license, so onward with Ubuntu it was. At this point in my life, I still had some interest in computer games, so I was on the &lt;a href=&quot;https://en.wikipedia.org/wiki/Wine_(software)&quot;&gt;Wine&lt;/a&gt; struggle bus trying to get Windows programs to run. The only game I remember actually getting to work was &lt;a href=&quot;https://en.wikipedia.org/wiki/Limbo_%28video_game%29&quot;&gt;Limbo&lt;/a&gt;, where I got a very jittery 20 FPS.&lt;/p&gt;

&lt;meta name=&quot;image&quot; property=&quot;og:image&quot; content=&quot;&quot; /&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/posts/PXL_20240629_175624646.jpg&quot; class=&quot;center&quot; width=&quot;384&quot; /&gt;&lt;/p&gt;
&lt;center&gt;&lt;em&gt;Some old Ubuntu install discs I found at my parents&apos; recently. My handwriting has not improved in the intervening years.&lt;/em&gt;&lt;/center&gt;

&lt;p&gt;For undergrad, I needed to use a laptop. Linux firmware support at the time was abysmal for such systems, so I switched to Windows to make my life easier. In grad school, however, I quickly found that systems development was a nightmare on Windows. I switched back, and was not disappointed.&lt;/p&gt;

&lt;p&gt;As an aside, I had two stints using a MacBook for internships in undergrad and grad school. I was amazed at the remarkable battery life those machines could achieve. I was not amazed by much else.&lt;/p&gt;

&lt;p&gt;These days, I dual boot PopOS (based on Ubuntu, but I may change soon) and Windows… 10? 11? I’m not even sure. I only boot into Windows ocassionally to use Adobe Lightroom for photo editing.&lt;/p&gt;

&lt;p&gt;Now, with the &lt;a href=&quot;https://www.windowscentral.com/microsoft/mitigation-actions-microsoft-cloudstrike-outages&quot;&gt;Windows BSOD nightmare&lt;/a&gt; last week, I was reminded of some reasons why I don’t think I can go back. I’ve ranted about these topics plenty of times to my wife and friends–none of whom care, and I don’t blame them–but maybe someone online will find my views insightful. Here is everything I want from an operating system.&lt;/p&gt;

&lt;p&gt;The perfect OS should…&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Not be locked down to any particular hardware.
    &lt;ul&gt;
      &lt;li&gt;Vertical integration has a couple of advantages, but they’re always outweighed by the cons in my view. I like choice, and I don’t like being price gouged.&lt;/li&gt;
      &lt;li&gt;This knocks out MacOS, so let’s not talk about that further.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Never reboot on its own.
    &lt;ul&gt;
      &lt;li&gt;I should never have to worry that my overnight compute process will be interrupted, unless I wrote bad code.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Never install or update any software without user approval.
    &lt;ul&gt;
      &lt;li&gt;This seems like common sense, and this alone would have avoided the CloudStrike mess. I know that enterprises have strict software enforcement policies, but at the very least the IT team of each company should have to manually approve each individual software update. It may be less convenient, but look where convenience got us.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Come with only the most basic software out of the box.
    &lt;ul&gt;
      &lt;li&gt;My software needs are different from yours. Why should we have software that we will never use?&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Not push the use of any particular software.
    &lt;ul&gt;
      &lt;li&gt;Make it easy to change software defaults and extension handlers. Allow me to remove any software that I don’t like.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Not be tied to a particular desktop environment.
    &lt;ul&gt;
      &lt;li&gt;If I want to completely change the look and feel of my system, I should be able to.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Allow me to change anything I want, without making it difficult.
    &lt;ul&gt;
      &lt;li&gt;With enough tinkering, I should be able to control anything I want to.&lt;/li&gt;
      &lt;li&gt;I should be able to install any software I want, by any means I want.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Not break when I change things.
    &lt;ul&gt;
      &lt;li&gt;Or, if it does break, make it easy to revert those changes. NixOS (and/or the Nix package manager) seem great in this regard, but I haven’t yet had the time to devote to learning them.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Not have any telemetry.
    &lt;ul&gt;
      &lt;li&gt;I’m not sure that any mainline OS can claim this, and the only way to guarantee it is to never connect the device to the Internet. Still, no telemetry is the ideal. Extremely limited and anonymous telemetry (as anonymous as can be, that is), is the baseline expectation.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Not have any “AI.”
    &lt;ul&gt;
      &lt;li&gt;I don’t want it or need it, except in very controlled circumstances. Generative AI built into an OS is a privacy nightmare, and unlikely to be very useful.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Not randomly eat up resources in the background.
    &lt;ul&gt;
      &lt;li&gt;A cause of rage any time I boot into Windows. No, I haven’t installed any updates in months, because I haven’t booted you up in months. That doesn’t give you the right to use 100% of my CPU to run a background update installer.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Not have advertisements.
    &lt;ul&gt;
      &lt;li&gt;I feel like this should be obvious, especially if it’s an OS I’ve paid for.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Get out of my way.
    &lt;ul&gt;
      &lt;li&gt;Don’t require me to do something in one particular way. Don’t have flashy animations. Don’t ask me twice if I want to perform some action.&lt;/li&gt;
      &lt;li&gt;I don’t need my operating system to be pretty or elegant. I don’t want to have to think about my operating system at all. It is merely a tool. I want it to get out of my way so I can do my work.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I wrote this list with desktop operating systems in mind, but I actually believe in these same principles for mobile operating systems, too. It should be obvious what kind of phone I have.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Advice for New PhD Students</title>
   <link href="https://acfreeman.dev/2024/05/10/phdadvice"/>
   <updated>2024-05-10T00:00:00+00:00</updated>
   <id>https://acfreeman.dev/2024/05/10/phdadvice</id>
   <content type="html">&lt;p&gt;I’m currently wrapping up my PhD in computer science, getting ready to enter the next season of my life and career. Looking back on the last five years, I’m very happy with how things have worked out. There are some things that I wish I had done differently, but I learned some valuable lessons along the way. The following is my advice for future PhD students, under my advisement or otherwise. I write from a Christian perspective, but several of these points may apply to non-believers. I’m also writing about what worked for &lt;em&gt;me&lt;/em&gt;, so your mileage may vary. I may update this list over the years as I gain experience as an advisor.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Your research and career are not your life
    &lt;ul&gt;
      &lt;li&gt;Don’t pin your worth on the success or failure of your research. We are children of God, and He calls us by name. While you can glorify God through the uncovering of new knowledge, all your material work will fade. The relationships you foster and the disciples you make here on Earth are what will last.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Your PhD work is a job, so treat it like one
    &lt;ul&gt;
      &lt;li&gt;As much as possible, try not to work on weekends. Try to keep a consistent 9-5 schedule. Sure, working 80 hours per week for 5 years may result in better research output and better job placement. But it will absolutely crush you, and there’s the law of diminishing returns. It’s not worth it. See point #1.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Be involved in your local church
    &lt;ul&gt;
      &lt;li&gt;Participate in a small group. Serve in some way. Be a leader, if you are called to that.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Have friends that aren’t grad students
    &lt;ul&gt;
      &lt;li&gt;You can still have friends that &lt;em&gt;are&lt;/em&gt; grad students, of course, but it can be easy for you to get caught up in the academic bubble. Seek out people with “real-world” jobs. They won’t want to talk about academia, so you’ll have to find other things to talk about. That’s a good thing. It helps keep you grounded in reality, more pleasant to be around, and better equipped to deal with stress.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Live away from campus, and only go to campus when necessary
    &lt;ul&gt;
      &lt;li&gt;You’re not a college student anymore, so you won’t really be interested in (or have the time for) all the hubbub of on-campus activities that the undergraduates engage in. It can be easy to get stuck in the college bubble if you live close to campus. Live a decent drive away, if you can, and have a physical separation between your work and personal life.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Have a designated workspace
    &lt;ul&gt;
      &lt;li&gt;If you’re most productive in the quiet of your home, work there. If you need to be in your lab or office on campus, work there. If you get energized by being in a coffee shop, work there.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Have hobbies
    &lt;ul&gt;
      &lt;li&gt;Have something productive and fun to do that is not work.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Try to start a family
    &lt;ul&gt;
      &lt;li&gt;I could have a broader discussion about the problems with modern dating, but just know that it will take considerable effort. If you want to get married, you have to make that a priority and work towards it. Put yourself in positions where you can meet a potential spouse (see point #3). Date intentionally. Date with purity. Date only for the amount of time that it takes to determine if this is a person you want to marry. Then get engaged and get married as soon as possible.&lt;/li&gt;
      &lt;li&gt;Having a spouse can change your entire outlook on your work and career. It’s no longer just about you. You are now forced (for the &lt;em&gt;better&lt;/em&gt;) to allocate time for another person. You can save on rent and expenses with a double income, especially if your spouse isn’t a student, freeing you up to invest your meager graduate stipend. Life becomes much more fun and fulfilling when you’re serving others, and marriage locks in that service for life. If you don’t find that person, however, don’t fret. Serve your church, your neighbors, and your friends.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Go on adventures
    &lt;ul&gt;
      &lt;li&gt;Ideally, you have a lot of flexibility with your time during grad school, and multiple opportunities to travel for research conferences. Take advantage of those! Travel as much as you can and explore the world.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Don’t be afraid of your advisor
    &lt;ul&gt;
      &lt;li&gt;A quick Google search will reveal many advisor horror stories spanning verbal abuse, impossible expectations, hypocrisy, and the like. It can be easy to feel like your advisor holds a lot of power over you. In reality, I think it’s less one-sided, especially in a small lab. Your advisor expects you to produce good research, and he or she can make or break your degree progress on that basis. At the same time, Your advisor &lt;em&gt;depends&lt;/em&gt; on you for that research, to some extent. If your advisor makes life difficult for you, then you won’t produce good work, which means it will be harder for him or her to secure grant funding in the future. If you have a really bad advisor, you’ll probably figure that out early on in your PhD journey. If you find yourself in that situation, you should &lt;em&gt;change advisors&lt;/em&gt;. That might mean a slight delay in your progress, but it will be worth it for your mental wellbeing.&lt;/li&gt;
      &lt;li&gt;Be honest with your advisor, even if critical. If I am ever overly difficult towards my students, hard to reach, tardy, etc., I hope that they will bring their concerns to me and we can have an honest conversation. I want to be open to criticism, because I know I have many flaws. We should always be trying to improve ourselves.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Don’t compare yourself to your peers
    &lt;ul&gt;
      &lt;li&gt;You will almost certainly get imposter syndrome, but you need to fight against that. Avoid the temptation to compare your research results (number of publications or citations, attention, popularity) to others, especially if their research is in a different topic. If you are making the above points a priority, then there are definitely other students who are working harder and longer hours than you to achieve that notoriety. Others benefit from access to better academic resources and connections. Still others simply get lucky. It’s okay to not be one of those people. You need to decide for yourself what you value and set reasonable goals for yourself.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ol&gt;

</content>
 </entry>
 
 <entry>
   <title>ADDER Codec</title>
   <link href="https://acfreeman.dev/2022/08/23/adder-codec"/>
   <updated>2022-08-23T00:00:00+00:00</updated>
   <id>https://acfreeman.dev/2022/08/23/ADDER-codec</id>
   <content type="html">&lt;meta name=&quot;image&quot; property=&quot;og:image&quot; content=&quot;/assets/images/posts/out_16bit_2_c10.jpg&quot; /&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/posts/out_16bit_2_c10.jpg&quot; class=&quot;center&quot; width=&quot;384&quot; height=&quot;216&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;adδer-codec&quot;&gt;ADΔER Codec&lt;/h2&gt;

&lt;p&gt;I’m excited to share a software library I’ve been working on called the &lt;strong&gt;ADΔER codec&lt;/strong&gt;. ADΔER stands for Address, Decimation, Δt Event Representation, which I’m pitching as a radical new way to think about video. This Rust library enables users to experiment with my asynchronous, event-driven video representation, and build applications which leverage it. To showcase some of my ideas, I put together a &lt;a href=&quot;https://yt-embed.herokuapp.com/embed?v=yfzwn5PrMpw&quot;&gt;demo&lt;/a&gt; with examples of transcoding framed video to ADΔER. I have a couple applications in the works which directly employ this library, which I hope to share in the coming months.&lt;/p&gt;

&lt;p&gt;This work is the culmination of three years of research into event video representations, but does not encompass all the work I’ve done. Rather, this is just the stuff that I polished up to a state where I felt comfortable releasing it out into the wild. I needed the pressure of making my code public in order to get it to a state where it’s at least somewhat documented and readable. More is coming soon, especially as I approach a paper deadline in October! In the meantime, refer to the project’s README for more information, and star/watch it on &lt;a href=&quot;https://github.com/ac-freeman/adder-codec-rs&quot;&gt;GitHub&lt;/a&gt; to receive updates. And of course, let me know if you have any questions by contacting me directly or creating an issue on GitHub.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Learning a New Language in a Weekend (Rust)</title>
   <link href="https://acfreeman.dev/2022/05/10/rust"/>
   <updated>2022-05-10T00:00:00+00:00</updated>
   <id>https://acfreeman.dev/2022/05/10/rust</id>
   <content type="html">&lt;meta name=&quot;image&quot; property=&quot;og:image&quot; content=&quot;/assets/images/posts/rust/rust-logo-256x256.png&quot; /&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/posts/rust/rust-logo-256x256.png&quot; class=&quot;center&quot; width=&quot;128&quot; height=&quot;128&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;the-state-of-things&quot;&gt;The state of things&lt;/h2&gt;

&lt;p&gt;85% of my time programming over the last few years has been in C++, 10% in Python, and 5% in MATLAB. The thing is, I don’t like programming in any of these languages.&lt;/p&gt;

&lt;p&gt;MATLAB is great for working on quick image processing tasks and big matrix operations. I used it quite a lot for a couple classes, and for some early prototyping of neural network designs. However, it would be far too slow for the video-oriented tasks I work on.&lt;/p&gt;

&lt;p&gt;Python is… a language I loathe, to put it bluntly. While it’s great for rapid prototyping, data science, and machine learning, it’s only fast when Python code isn’t running. That is, you have to call on all sorts of packages which use underlying C code in order to achieve serious performance. That feels wrong to me, and it makes debugging a nightmare. I generally only use Python for machine learning programs with PyTorch, or for quick data transformation tasks.&lt;/p&gt;

&lt;p&gt;C++ is fast, but it can be a nightmare to program in. You’re exposed to all sorts of memory bugs that can hide out for months and be extremely difficult to track down. Using #include statements is a nightmare without a package manager, especially when moving between machines with different library versions installed. CMake makes this a bit better, but getting that to work reliably is also a pain. The language is frustrating to write in, and it often got in the way of me making progress on my work.&lt;/p&gt;

&lt;p&gt;My favorite language I’ve ever used is Elixir, a functional language for back-end systems designed for massive concurrency and resiliency. Unfortunately, Elixir is ill-suited to my research, so I haven’t touched it in a few years.&lt;/p&gt;

&lt;h2 id=&quot;enter-rust&quot;&gt;Enter Rust&lt;/h2&gt;

&lt;p&gt;A few months ago, I got fed up with C++. I wanted a change. I wanted to enjoy programming again, and feel empowered to work on the research itself, rather than have to spend so much time chasing down bugs and optimizations. A colleague of mine had badgered me about a language called Rust for upwards of a year, so I decided to check it out. My wife had a weekend shift at her work, so I was working through the weekend, too. I started reading the &lt;a href=&quot;https://doc.rust-lang.org/book/&quot;&gt;Rust Book&lt;/a&gt; on a Saturday morning.&lt;/p&gt;

&lt;p&gt;I quickly learned that Rust can be as performant as C code, while providing some seriously impressive guarantees about memory safety through a borrow checker. Every piece of data has an owner, and there can only be one mutable reference to a value at time. This makes concurrency much safer, since the compiler strictly enforces these rules. Parallelizing a piece of code can be much more difficult in some cases than in C++, sometimes requiring clever organizations of struct members, but it’s a worthwhile tradeoff for the memory guarantees. I’d rather spend my time writing safe code than debugging unsafe code. Furthermore, it has a simple, modern package manager provide by the Cargo system.&lt;/p&gt;

&lt;p&gt;By Monday morning, two days after starting to read the documentation, I had rewritten the bulk of my exisiting code base for asynchronous camera emulation entirely in Rust. It was that easy. The kicker? It was already faster than my C++/CUDA implementation. Upon having that realization, I was converted. For the last couple of months since then, I’ve done all my further development in Rust, and worked to further optimize it as I learn new features of the language and discover helpful packages. Admittedly, there are some things that continue to cause me headaches (maybe I’ll write about them later), but all in all this has made my work life much more enjoyable. I hope to release my new Rust codebase sometime this summer, once I get it packaged more nicely.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Provisioning a Fresh Ubuntu Installation with Bash</title>
   <link href="https://acfreeman.dev/2021/07/19/config"/>
   <updated>2021-07-19T00:00:00+00:00</updated>
   <id>https://acfreeman.dev/2021/07/19/config</id>
   <content type="html">&lt;meta name=&quot;image&quot; property=&quot;og:image&quot; content=&quot;/assets/images/posts/config/desktop.png&quot; /&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/posts/config/desktop.png&quot; alt=&quot;Ubuntu desktop&quot; class=&quot;center&quot; style=&quot;height: 80%; width: 80%; object-fit: contain&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Last year I started keeping track of the packages I was installing, anticipating a time where I would need to start afresh with a clean Ubuntu installation. I have a running list of installation commands in a bash file which I can run all at once, without having to think about it. This worked marvelously during my &lt;a href=&quot;https://acfreeman.dev/2021/07/17/opencv-bad&quot;&gt;OpenCV fiasco&lt;/a&gt; last week, allowing me to get everything back the way I liked it with minimal effort on my part.&lt;/p&gt;

&lt;p&gt;Here’s the &lt;a href=&quot;https://github.com/andrewcfreeman/Linux-Config&quot;&gt;repository&lt;/a&gt;, in case you’re interested. I target Ubuntu 20.04 LTS, since that’s what I’m using for the forseeable future, but you can adapt to suit your distro. MATLAB still requires manual installation, and I have to manually enable my GNOME extensions to make the desktop more space-efficient (I use Dash to Panel, and have my settings backed up in a config file on the repo). In the future I also want to be able to automatically set my custom keyboard shortcuts and configure my IDEs and code editors. But all in all, I’ve found it to be a pretty good solution for me. I can get a new system looking and behaving just the way I want it to, with all my desired programs ready to go, with just a few clicks and some waiting around.&lt;/p&gt;

</content>
 </entry>
 
 <entry>
   <title>Ruining a Linux Installation with OpenCV</title>
   <link href="https://acfreeman.dev/2021/07/17/opencv-bad"/>
   <updated>2021-07-17T00:00:00+00:00</updated>
   <id>https://acfreeman.dev/2021/07/17/opencv-bad</id>
   <content type="html">&lt;meta name=&quot;image&quot; property=&quot;og:image&quot; content=&quot;/assets/images/posts/opencv-bad/logo.png&quot; /&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/posts/opencv-bad/logo.png&quot; alt=&quot;OpenCV logo&quot; class=&quot;center&quot; style=&quot;height: 30%; width: 30%; object-fit: contain&quot; /&gt;&lt;/p&gt;

&lt;p&gt;OpenCV is a behemoth of a library. It’s really useful, but my goodness is it a pain to work with sometimes.&lt;/p&gt;

&lt;p&gt;This week I was trying to compile OpenCV to be able to get faster optical flow performance with CUDA. I needed to recompile OpenCV with the CUDA flags enabled. I also needed FFMPEG support to process full videos. I had upgraded my FFMPEG a few weeks ago to version &lt;a href=&quot;http://ffmpeg.org/download.html#release_4.4&quot;&gt;4.4&lt;/a&gt;, because it was hard resetting my machine every time I tried to rescale a video (the CPU would quickly hit 100% and then crash). But apparently the latest FFMPEG update broke the OpenCV bindings. Fine, I’ll downgrade FFMPEG for now and find a workaround or have another version in a container, I said. I also needed CuDNN, but I’m not sure how much that contributed to my problem.&lt;/p&gt;

&lt;p&gt;Anyway, everything broke. I started getting all sorts of CUDA build errors, so I tried upgrading to CUDA 11.4. I tried different Nvidia drivers. I tried building older, better tested versions of OpenCV but that led to a myriad of errors related to the FFMPEG codecs not being available or having improper function definitions even though they were installed and working correctly. I spent &lt;strong&gt;three days&lt;/strong&gt; straight trying to fix it before giving up. OpenCV was irrevocably broken, and I was tired of it. I think somewhere along the line I tried “installing” my OpenCV build with &lt;code&gt;make install&lt;/code&gt;, and that can apparently cause issues with updating system packages.&lt;/p&gt;

&lt;p&gt;I tried getting my programs running on Windows, and I got &lt;em&gt;very close&lt;/em&gt; but abandoned that for now. OpenCV and CUDA are even more difficult to work with in a CMake application on Windows. I don’t want to use a full Visual Studio solution because 1) Visual Studio is bloated and I don’t like it, and 2) having cross-platform code is unimportant when there’s only one person working on it and using it right now (me). So I threw my hands up and decided to wipe the slate clean with a fresh Ubuntu install.&lt;/p&gt;

&lt;p&gt;And that worked great. Perfectly. My program runs again, on the latest version of OpenCV, compiled with CUDA, and I can continue doing the work that matters. It’s just frustrating to me that OpenCV isn’t more modular and user-friendly. It’s so easy to break! While I’m ranting, there’s an undue amount of effort put into the Python documentation, considering the library is written in C/C++. The C++ docs are terrible and most of the example code is horribly outdated. The library is way too big, and I should be able to more easily add/drop modules as I wish without having to recompile the whole thing. It’s so large that it’s impractical to containerize on a personal machine with limited storage. It’s amazing and powerful when it works, but when it doesn’t… I want to rip my hair out.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>C++ Raw Pointer vs. Smart Pointer Performance with 1 Million Linked Lists</title>
   <link href="https://acfreeman.dev/2020/07/10/pointers"/>
   <updated>2020-07-10T00:00:00+00:00</updated>
   <id>https://acfreeman.dev/2020/07/10/pointers</id>
   <content type="html">&lt;meta name=&quot;image&quot; property=&quot;og:image&quot; content=&quot;/assets/images/posts/pointers/Screenshot from 2020-07-10 10-54-47.png&quot; /&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/posts/pointers/Screenshot from 2020-07-10 10-54-47.png&quot; alt=&quot;Early look at Massif memory allocation results&quot; class=&quot;center&quot; /&gt;&lt;/p&gt;

&lt;p&gt;In my research work, I need to maintain about 1,000,000 linked lists, with each growing to about 100 nodes and frequently deleting the head. These lists initially populate by reading in data from a file in a matter of seconds, and I’m aiming for &amp;lt;1 millisecond performance to add one new node to all the lists. Each node occupies 29 bytes of storage, including the pointer to the next node. That’s 2.7 GB of data that needs to be processed and managed with minimal overhead. At this scale and with the particular target application, every nanosecond counts.&lt;/p&gt;

&lt;p&gt;The conventional wisdom for this problem would be to use smart pointers to manage the node references, especially since the nodes themselves must contain the pointers and the nodes are deleted by a function from a different class. &lt;code&gt;unique_ptrs&lt;/code&gt; are the fastest, with the  &lt;a href=&quot;http://www.cplusplus.com/reference/memory/unique_ptr/&quot; target=&quot;_blank&quot;&gt;CPP docs&lt;/a&gt; saying they offer “little to no overhead over built-in pointers (depending on the deleter used).” So I took their word for it and used &lt;code&gt;unique_ptr&lt;/code&gt; references in my nodes with the default deleter. But the performance was awful. Truly bad.&lt;/p&gt;

&lt;p&gt;I set up the following test to verify that the use of smart pointers was the culprit, making sure to allocate and populate the memory realistically, as well as test deleting and reinitializing data. Here’s the code to test raw pointer performance:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-c--&quot; data-lang=&quot;c++&quot;&gt;&lt;span class=&quot;cp&quot;&gt;#include&lt;/span&gt; &lt;span class=&quot;cpf&quot;&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;using&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cerr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;using&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cout&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;using&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;endl&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;using&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ostream&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;cp&quot;&gt;#include&lt;/span&gt; &lt;span class=&quot;cpf&quot;&gt;&amp;lt;chrono&amp;gt;&lt;/span&gt;&lt;span class=&quot;c1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;cp&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;using&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;namespace&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;chrono&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; 
  
&lt;span class=&quot;cp&quot;&gt;#include&lt;/span&gt; &lt;span class=&quot;cpf&quot;&gt;&amp;lt;array&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt;
#include&lt;/span&gt; &lt;span class=&quot;cpf&quot;&gt;&amp;lt;cstdint&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt;
&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Node&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;nl&quot;&gt;private:&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;Node&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kt&quot;&gt;double&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;d1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kt&quot;&gt;double&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;d2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kt&quot;&gt;double&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;d3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;nl&quot;&gt;public:&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;Node&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;Node&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;double&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;d1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;double&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;d2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;double&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;d3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;Node&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;getNext&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;

    &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;addNext&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;count&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;arr_size&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1000000&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;list_size&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;Node&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Node&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;next&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;nullptr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;Node&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Node&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;getNext&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;Node&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Node&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;double&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;d1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;double&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;d2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;double&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;d3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;d1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;d2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;d3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;next&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;nullptr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Node&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;addNext&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;count&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;count&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;list_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;next&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Node&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;d2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;d3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;addNext&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;count&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;Node&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;deleteTest&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Node&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;Node&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;old_head&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;head&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;getNext&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;delete&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;old_head&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;argc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;argv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[])&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;auto&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;start&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;high_resolution_clock&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;now&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt; 
    &lt;span class=&quot;n&quot;&gt;Node&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;**&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;nodes&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Node&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;arr_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;arr_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;nodes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Node&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;nodes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;addNext&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

     &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;j&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;j&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;arr_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;j&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;list_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;nodes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;j&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;deleteTest&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;nodes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;j&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]);&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;delete&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nodes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;j&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;arr_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;nodes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Node&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;nodes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;addNext&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

     &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;j&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;j&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;arr_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;j&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;list_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;nodes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;j&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;deleteTest&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;nodes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;j&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]);&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;delete&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nodes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;j&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;delete&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nodes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    
    &lt;span class=&quot;k&quot;&gt;auto&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;stop&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;high_resolution_clock&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;now&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt; 
    &lt;span class=&quot;n&quot;&gt;cout&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Finished in &quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;duration_cast&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;milliseconds&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stop&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;start&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;count&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot; milliseconds&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;endl&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;And here’s the code to test &lt;code&gt;unique_ptr&lt;/code&gt; performance:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-c--&quot; data-lang=&quot;c++&quot;&gt;&lt;span class=&quot;cp&quot;&gt;#include&lt;/span&gt; &lt;span class=&quot;cpf&quot;&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;using&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cerr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;using&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cout&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;using&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;endl&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;cp&quot;&gt;#include&lt;/span&gt; &lt;span class=&quot;cpf&quot;&gt;&amp;lt;chrono&amp;gt;&lt;/span&gt;&lt;span class=&quot;c1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;cp&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;using&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;namespace&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;chrono&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; 

&lt;span class=&quot;cp&quot;&gt;#include&lt;/span&gt; &lt;span class=&quot;cpf&quot;&gt;&amp;lt;iomanip&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt;
#include&lt;/span&gt; &lt;span class=&quot;cpf&quot;&gt;&amp;lt;array&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt;
#include&lt;/span&gt; &lt;span class=&quot;cpf&quot;&gt;&amp;lt;cstdint&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt;
&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Node&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;nl&quot;&gt;private:&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;unique_ptr&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Node&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kt&quot;&gt;double&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;d1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kt&quot;&gt;double&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;d2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kt&quot;&gt;double&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;d3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;nl&quot;&gt;public:&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;Node&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;Node&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;double&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;d1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;double&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;d2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;double&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;d3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;unique_ptr&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Node&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;getNext&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;

    &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;addNext&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;count&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;arr_size&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1000000&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;list_size&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;Node&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Node&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;next&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;nullptr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;unique_ptr&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Node&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Node&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;getNext&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;move&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;Node&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Node&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;double&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;d1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;double&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;d2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;double&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;d3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;d1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;d2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;d3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;next&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;nullptr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Node&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;addNext&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;count&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;count&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;list_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;next&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;make_unique&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Node&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;d2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;d3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;addNext&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;count&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;unique_ptr&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Node&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;deleteTest&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;unique_ptr&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Node&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;unique_ptr&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Node&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;old_head&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;swap&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;old_head&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;head&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;old_head&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;getNext&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;old_head&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;reset&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;argc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;argv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[])&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;auto&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;start&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;high_resolution_clock&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;now&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt; 
    &lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;unique_ptr&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Node&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;nodes&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;unique_ptr&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Node&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;arr_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;arr_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;nodes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;make_unique&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Node&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;nodes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;addNext&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;j&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;j&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;arr_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;j&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;list_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;nodes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;j&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;deleteTest&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;move&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;nodes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;j&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]));&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;nodes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;j&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;reset&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;arr_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;nodes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;make_unique&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Node&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;nodes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;addNext&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;j&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;j&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;arr_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;j&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;list_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;nodes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;j&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;deleteTest&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;move&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;nodes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;j&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]));&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;nodes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;j&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;reset&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;    
    &lt;span class=&quot;k&quot;&gt;delete&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nodes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    
    &lt;span class=&quot;k&quot;&gt;auto&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;stop&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;high_resolution_clock&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;now&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt; 
    &lt;span class=&quot;n&quot;&gt;cout&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Finished in &quot;&lt;/span&gt; 
         &lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;duration_cast&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;milliseconds&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stop&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;start&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;count&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; 
         &lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot; milliseconds&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;endl&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Here were my results from running the programs in a terminal:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/posts/pointers/Screenshot from 2020-07-10 10-35-26.png&quot; alt=&quot;Raw vs smart results&quot; class=&quot;center&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The raw pointers performed about 6% better than the &lt;code&gt;unique_ptrs&lt;/code&gt; on my machine. This may not seem like a huge difference, but as I said above it really adds up noticeably over the program lifecyle. Things get particularly bad, however, when I’m tyring to debug the code.&lt;/p&gt;

&lt;p&gt;Debugging in Visual Studio Code I achieve only a minor slowdown with the raw pointers over their straight execution:
&lt;img src=&quot;/assets/images/posts/pointers/Screenshot from 2020-07-10 10-43-54.png&quot; alt=&quot;Raw debug&quot; class=&quot;center&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Meanwhile the use of &lt;code&gt;unique_ptrs&lt;/code&gt; caused a 24X slowdown when debugging:
&lt;img src=&quot;/assets/images/posts/pointers/Screenshot from 2020-07-10 10-43-23.png&quot; alt=&quot;Smart debug&quot; class=&quot;center&quot; /&gt;&lt;/p&gt;

&lt;p&gt;With my approach to development, such a slowdown is intolerable. At this stage in my project, I often need to debug and step through large chunks of my code in the middle of execution (after several GB of data have been processed). So I’ll gladly take the higher risk of using raw pointers over the severe debugging bottleneck of smart pointers, in this case.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Emulating Clock Tick for Parallelized Event Generation</title>
   <link href="https://acfreeman.dev/2020/06/23/openmp"/>
   <updated>2020-06-23T00:00:00+00:00</updated>
   <id>https://acfreeman.dev/2020/06/23/openmp</id>
   <content type="html">&lt;p&gt;&lt;img src=&quot;/assets/images/posts/annotated_class_50fps_crop.jpg&quot; alt=&quot;Reconstructed image from events&quot; class=&quot;center&quot; /&gt;&lt;/p&gt;

&lt;p&gt;For my current research project, I’m developing an asynchronous camera emulator that reads in Blender-rendered frames and outputs a stream of event data. Each pixel of the simulated sensor can output multiple events over each reference interval (the exposure time of each input frame), and each pixel may change the light sensitivity of other pixels around it (which in turn affects when those pixels will fire their next events).&lt;/p&gt;

&lt;p&gt;The details of this particular program aren’t important to understand, but they led me to the following issue.&lt;/p&gt;

&lt;p&gt;&lt;i&gt;How can I ensure the emulated pixels are accurately affecting each other at the right points in time? And how can I parallelize it to run faster?&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;Working under the necessary assumption that the rate of light integration is constant for a given input image, I needed to divide up the light data to my emulated pixels and deliver it, piece by piece, in a time-ordered manner. The delivery of this data &lt;b&gt;must&lt;/b&gt; be sequentially accurate. The solution I came up with was to have a &lt;code&gt;TEMPORAL_ACCURACY&lt;/code&gt; parameter which may be chosen at runtime. This variable essentially determines the number of timeslices we divide the reference interval into, and we divide each input image’s data into as many pieces. This data is integrated sequentially in each pixel. At this step I was able to parallelize the integration, since the pixels only affect each other’s sensitivities for the &lt;i&gt;next&lt;/i&gt; timeslice, and the threads synchronize at the end of each timeslice.&lt;/p&gt;

&lt;p&gt;Here’s the relevant C++ snippet using OpenMP to parallelize:&lt;/p&gt;
&lt;pre&gt;
double ref_time = (frame_length / TEMPORAL_ACCURACY);
for (int timeframe = 0; timeframe &amp;lt; TEMPORAL_ACCURACY; timeframe += 1)
{
	int x, y;
#pragma omp parallel for private(y) schedule(dynamic)
	for (y = 0; y &amp;lt; image.height(); y++)
	{
#pragma omp parallel for private(x) schedule(dynamic)
		for (x = 0; x &amp;lt; image.width(); x++)
		{
			double *bw = image.data(x, y, 0, 0); // get grayscale pixel intensity
			pixels[y][x].integrate((*bw / TEMPORAL_ACCURACY), ref_time);
		}
	}
}
&lt;/pre&gt;

&lt;p&gt;The &lt;code&gt;TEMPORAL_ACCURACY&lt;/code&gt;, therefore, is a sliding scale directly proportional to the accuracy of the emulation, but inversely proportional to the speed of the emulation. If &lt;code&gt;TEMPORAL_ACCURACY = frame_length&lt;/code&gt;, then we have a perfect 1:1 emulated clock tick and perfectly accurate results. &lt;code&gt;frame_length&lt;/code&gt; is measured in nanoseconds, however, so the necessary tradeoff is to sacrifice some accuracy for higher speed. I have found satisfactory results for a &lt;code&gt;frame_length&lt;/code&gt; of 10000000 when using a &lt;code&gt;TEMPORAL_ACCURACY&lt;/code&gt; of 100, such that each timeslice represents the passage of 100000 clock ticks.&lt;/p&gt;

&lt;p&gt;With a somewhat low-resolution (but realistic for the camera in question) emulated sensor of 360x240, I can achieve nearly real-time emulation speeds even with a complex sensitivity adjustment scheme. This means that the computation and output of events generated from a given input image takes roughly the same amount of time as the input frame’s exposure. The bottleneck here seems to actually be slow write performance of my NVME SSD, since all the events are written directly to disk.&lt;/p&gt;

&lt;p&gt;I’m not in a position to share the full code of this project at this time, but I can give you more details or answer any questions if you e-mail me. I should have a paper proposal ready in the next month or two, if you’re interested.&lt;/p&gt;
</content>
 </entry>
 

</feed>
